Skip to content

Commit

Permalink
Add the ability to specify the tags you whish to place on archives me…
Browse files Browse the repository at this point in the history
…ssages (#2800)
  • Loading branch information
preardon authored Sep 4, 2023
1 parent 438938b commit ed035c6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
11 changes: 1 addition & 10 deletions src/Paramore.Brighter.Archive.Azure/AzureBlobArchiveProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ private BlobUploadOptions GetUploadOptions(Message message)
};

if (_options.TagBlobs)
{
opts.Tags = new Dictionary<string, string>()
{
{ "topic", message.Header.Topic },
{ "correlationId", message.Header.CorrelationId.ToString() },
{ "message_type", message.Header.MessageType.ToString() },
{ "timestamp", message.Header.TimeStamp.ToString() },
{ "content_type", message.Header.ContentType }
};
}
opts.Tags = _options.TagsFunc.Invoke(message);

return opts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ public class AzureBlobArchiveProviderOptions
/// The maximum upload size in mb
/// </summary>
public int MaxUploadSize = 50;

/// <summary>
/// The function to arrange the tags to add when storing, please note that <see cref="TagBlobs"/> must be True for these to be used
/// </summary>
public Func<Message, Dictionary<string, string>> TagsFunc = (message) => new Dictionary<string, string>()
{
{ "topic", message.Header.Topic },
{ "correlationId", message.Header.CorrelationId.ToString() },
{ "message_type", message.Header.MessageType.ToString() },
{ "timestamp", message.Header.TimeStamp.ToString() },
{ "content_type", message.Header.ContentType }
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,15 @@ private BlobContainerClient GetClient(AccessTier tier , bool tags = false )
BlobContainerUri = new Uri("https://brighterarchivertest.blob.core.windows.net/messagearchive"),
TokenCredential = new AzureCliCredential(),
AccessTier = tier,
TagBlobs = tags

TagBlobs = tags,
TagsFunc = (message => new Dictionary<string, string>()
{
{ "topic", message.Header.Topic },
{ "correlationId", message.Header.CorrelationId.ToString() },
{ "message_type", message.Header.MessageType.ToString() },
{ "timestamp", message.Header.TimeStamp.ToString() },
{ "content_type", message.Header.ContentType }
})
};
_provider = new AzureBlobArchiveProvider(options);

Expand Down

0 comments on commit ed035c6

Please sign in to comment.