-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compression and JustSaying 8.0 Changes #1525
base: main
Are you sure you want to change the base?
Changes from 33 commits
a58a62b
cc7d4d3
2d3c495
426030d
e9a8a77
ddead74
37eaa73
09413c3
ab075b0
d1dd060
fff6506
aa326ce
c9ec0f9
a4ef78c
619b199
ce4b6d4
b3e5222
82a0bca
cd4f61b
7c18a0d
df43e02
8c23f2f
b0ea0ef
4d732a0
d888b5a
c593ef6
3657d8d
d644e48
6c04948
cb8e0fd
fe1d325
140ba8e
8ca09ad
d2b2a8f
fbe31d9
64e0d21
ee7febf
ef110b8
8de4441
3872c83
7e016e6
d549a5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"AWSRegion": "eu-west-1", | ||
"AWSServiceUrl": "http://localhost:4100" | ||
"AWSServiceUrl": "http://localhost:4566" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"AWSRegion": "eu-west-1", | ||
"AWSServiceUrl": "http://localhost:4100", | ||
"AWSServiceUrl": "http://localhost:4566", | ||
"AllowedHosts": "*" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using JustSaying.AwsTools.QueueCreation; | ||
using JustSaying.Fluent; | ||
using JustSaying.Messaging.Channels.Receive; | ||
using JustSaying.Messaging.Compression; | ||
using JustSaying.Messaging.MessageHandling; | ||
using JustSaying.Messaging.MessageSerialization; | ||
using JustSaying.Messaging.Middleware.Logging; | ||
|
@@ -31,7 +32,7 @@ public JustSayingRegistry() | |
For<IAwsClientFactoryProxy>().Use((p) => new AwsClientFactoryProxy(p.GetInstance<IAwsClientFactory>)).Singleton(); | ||
For<IMessagingConfig>().Use<MessagingConfig>().Singleton(); | ||
For<IMessageMonitor>().Use<NullOpMessageMonitor>().Singleton(); | ||
For<IMessageSerializationFactory>().Use<NewtonsoftSerializationFactory>().Singleton(); | ||
For<IMessageBodySerializationFactory>().Use<NewtonsoftSerializationFactory>().Singleton(); | ||
For<IMessageSubjectProvider>().Use<GenericMessageSubjectProvider>().Singleton(); | ||
For<IVerifyAmazonQueues>().Use<AmazonQueueCreator>().Singleton(); | ||
|
||
|
@@ -41,18 +42,7 @@ public JustSayingRegistry() | |
|
||
For<LoggingMiddleware>().Transient(); | ||
For<SqsPostProcessorMiddleware>().Transient(); | ||
|
||
For<IMessageSerializationRegister>() | ||
.Use( | ||
nameof(IMessageSerializationRegister), | ||
(p) => | ||
{ | ||
var config = p.GetInstance<IMessagingConfig>(); | ||
var serializerFactory = p.GetInstance<IMessageSerializationFactory>(); | ||
return new MessageSerializationRegister(config.MessageSubjectProvider, serializerFactory); | ||
}) | ||
.Singleton(); | ||
|
||
For<MessageCompressionRegistry>().Use((p) => new MessageCompressionRegistry(new List<IMessageBodyCompression> { new GzipMessageBodyCompression() })).Singleton(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
For<IMessageReceivePauseSignal>().Use<MessageReceivePauseSignal>().Singleton(); | ||
|
||
For<DefaultNamingConventions>().Singleton(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace JustSaying.AwsTools; | ||
|
||
/// <summary> | ||
/// Contains constant key values for message attributes. | ||
/// </summary> | ||
internal static class MessageAttributeKeys | ||
{ | ||
/// <summary> | ||
/// Represents the key for the Content-Encoding attribute. | ||
/// </summary> | ||
public const string ContentEncoding = "Content-Encoding"; | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||
namespace JustSaying.AwsTools.MessageHandling; | ||||||
|
||||||
/// <summary> | ||||||
/// Represents options for message compression during publishing. | ||||||
/// </summary> | ||||||
public sealed class PublishCompressionOptions | ||||||
{ | ||||||
/// <summary> | ||||||
/// Gets or sets the message length threshold in bytes. | ||||||
/// Messages larger than this threshold will be compressed. | ||||||
/// </summary> | ||||||
/// <remarks> | ||||||
/// The default value is 262,144 bytes (256 KB). | ||||||
/// </remarks> | ||||||
public int MessageLengthThreshold { get; set; } = 256 * 1024; | ||||||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
/// <summary> | ||||||
/// Gets or sets the compression encoding to be used. | ||||||
/// </summary> | ||||||
/// <remarks> | ||||||
/// This should correspond to a registered compression algorithm in the IMessageCompressionRegistry. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// </remarks> | ||||||
public string CompressionEncoding { get; set; } | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,18 @@ | |
|
||
namespace JustSaying.AwsTools.MessageHandling.Dispatch; | ||
|
||
public class MessageDispatcher : IMessageDispatcher | ||
internal class MessageDispatcher : IMessageDispatcher | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we seal it now if it's internal? |
||
{ | ||
private readonly IMessageSerializationRegister _serializationRegister; | ||
private readonly IMessageMonitor _messagingMonitor; | ||
private readonly MiddlewareMap _middlewareMap; | ||
|
||
private static ILogger _logger; | ||
|
||
public MessageDispatcher( | ||
IMessageSerializationRegister serializationRegister, | ||
IMessageMonitor messagingMonitor, | ||
MiddlewareMap middlewareMap, | ||
ILoggerFactory loggerFactory) | ||
{ | ||
_serializationRegister = serializationRegister; | ||
_messagingMonitor = messagingMonitor; | ||
_middlewareMap = middlewareMap; | ||
_logger = loggerFactory.CreateLogger("JustSaying"); | ||
|
@@ -68,18 +65,18 @@ public async Task DispatchMessageAsync( | |
|
||
await middleware.RunAsync(handleContext, null, cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
} | ||
|
||
private async Task<(bool success, Message typedMessage, MessageAttributes attributes)> | ||
DeserializeMessage(IQueueMessageContext messageContext, CancellationToken cancellationToken) | ||
{ | ||
try | ||
{ | ||
_logger.LogDebug("Attempting to deserialize message with serialization register {Type}", | ||
_serializationRegister.GetType().FullName); | ||
var messageWithAttributes = _serializationRegister.DeserializeMessage(messageContext.Message.Body); | ||
return (true, messageWithAttributes.Message, messageWithAttributes.MessageAttributes); | ||
_logger.LogDebug("Attempting to deserialize message."); | ||
|
||
var (message, attributes) = messageContext.MessageConverter.ConvertForReceive(messageContext.Message); | ||
|
||
return (true, message, attributes); | ||
} | ||
catch (MessageFormatNotSupportedException ex) | ||
{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move types to dedicated files with the appropriate names. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using JustSaying.AwsTools.MessageHandling; | ||
using JustSaying.Messaging.MessageSerialization; | ||
using JustSaying.Models; | ||
|
||
namespace JustSaying.Messaging; | ||
|
||
public interface IPublishMessageConverter | ||
{ | ||
PublishMessage ConvertForPublish(Message message, PublishMetadata publishMetadata, PublishDestinationType destinationType); | ||
} | ||
|
||
public interface IReceivedMessageConverter | ||
{ | ||
ReceivedMessage ConvertForReceive(Amazon.SQS.Model.Message message); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any need to make these async? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps, right now no, but we could later expand it to do "fetch from S3". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah the claim-check thing was what was in the back of my mind. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,4 +76,4 @@ Task ChangeMessageVisibilityAsync( | |
int visibilityTimeoutInSeconds, | ||
CancellationToken cancellationToken); | ||
|
||
} | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace JustSaying.AwsTools.MessageHandling; | ||
|
||
public enum PublishDestinationType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When near completion we should add |
||
{ | ||
Topic = 1, | ||
Queue = 2 | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make whatever the default/typical one is |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we resolved all the compressions from DI and then just registered GZip as the only one?