-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor message handling interfaces and add new transport abstractions #1
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
Changes from all commits
1715090
d643e3c
5f03cc1
89e9bb2
7cf31ad
9d1bafe
6deeac7
980b5f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| /// <summary> | ||
| /// Command message marker interface | ||
| /// </summary> | ||
| public interface ICommand : IMessage {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| public interface ICommandHandler<TCommand> | ||
| where TCommand : ICommand | ||
| { | ||
| Task HandleAsync(TCommand command, CancellationToken cancellationToken); | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| /// <summary> | ||
| /// Event message marker interface | ||
| /// </summary> | ||
| public interface IEvent : IMessage {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| public interface IEventHandler<TEvent> | ||
| where TEvent : IEvent | ||
| { | ||
| Task HandleAsync(TEvent @event, CancellationToken cancellationToken); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,14 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| // Message base interface | ||
| public interface IMessage | ||
| { | ||
| /// <summary> | ||
| /// It will be used for Saga, Idempotency, etc. | ||
| /// </summary> | ||
| Guid MessageId { get; } | ||
| DateTime Timestamp { get; } | ||
|
|
||
| } | ||
|
|
||
| // Pipelines and middlewares | ||
| public interface IMessageMiddleware | ||
| { | ||
| } | ||
|
|
||
| public interface IPublishPipeline | ||
| { | ||
| } | ||
|
|
||
| public interface IConsumerPipeline | ||
| { | ||
| } | ||
|
|
||
| // Policies and erros | ||
| public interface IErrorHandler | ||
| { | ||
| } | ||
|
|
||
| public interface IRetryPolicy | ||
| { | ||
| } | ||
|
|
||
| public interface IExceptionFilter | ||
| { | ||
|
|
||
| } | ||
|
|
||
| // Telemetry - it will be integrated with OpenTelemetry | ||
| public interface ITracerAdapter | ||
| { | ||
|
|
||
| /// <summary> | ||
| /// It will be used for logging, tracing, etc. | ||
| /// </summary> | ||
| DateTime Timestamp { get; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| public interface IQuery<TResult> : IMessage {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace UltraSpeedBus.Abstractions.Message; | ||
|
|
||
| public interface IQueryHandler<TQuery, TResult> | ||
| where TQuery : IQuery<TResult> | ||
| { | ||
| Task HandleAsync(TQuery query, CancellationToken cancellationToken); | ||
| } | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||
| namespace UltraSpeedBus.Abstractions.Message; | ||||||
|
||||||
| namespace UltraSpeedBus.Abstractions.Message; | |
| namespace UltraSpeedBus.Abstractions.Transport; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,23 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace UltraSpeedBus.Abstractions.Transport; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace UltraSpeedBus.Abstractions.Message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace UltraSpeedBus.Abstractions.Message; | |
| namespace UltraSpeedBus.Abstractions.Transport; |
Copilot
AI
Nov 18, 2025
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.
The ConsumerTransportContext class is empty and has no properties or methods. This makes it unusable for passing context information to message handlers. It should include at minimum the MessageEnvelope and methods for message completion/abandonment similar to the deleted version.
| { | |
| { | |
| /// <summary> | |
| /// The envelope containing the message and metadata. | |
| /// </summary> | |
| public MessageEnvelope Envelope { get; } | |
| private readonly Func<Task> _completeAsync; | |
| private readonly Func<Task> _abandonAsync; | |
| /// <summary> | |
| /// Initializes a new instance of the <see cref="ConsumerTransportContext"/> class. | |
| /// </summary> | |
| /// <param name="envelope">The message envelope.</param> | |
| /// <param name="completeAsync">Delegate to complete the message.</param> | |
| /// <param name="abandonAsync">Delegate to abandon the message.</param> | |
| public ConsumerTransportContext( | |
| MessageEnvelope envelope, | |
| Func<Task> completeAsync, | |
| Func<Task> abandonAsync) | |
| { | |
| Envelope = envelope; | |
| _completeAsync = completeAsync ?? throw new ArgumentNullException(nameof(completeAsync)); | |
| _abandonAsync = abandonAsync ?? throw new ArgumentNullException(nameof(abandonAsync)); | |
| } | |
| /// <summary> | |
| /// Marks the message as successfully processed. | |
| /// </summary> | |
| public Task CompleteAsync() => _completeAsync(); | |
| /// <summary> | |
| /// Abandons the message, indicating it was not processed successfully. | |
| /// </summary> | |
| public Task AbandonAsync() => _abandonAsync(); |
Copilot
AI
Nov 18, 2025
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.
The ConsumerTransportContext class is defined in ITransportConsumer.cs, but should be in its own file ConsumerTransportContext.cs for better code organization and maintainability.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,20 @@ | ||||||||||||||||||
| using UltraSpeedBus.Abstractions.Message; | ||||||||||||||||||
| namespace UltraSpeedBus.Abstractions.Message; | ||||||||||||||||||
|
||||||||||||||||||
| namespace UltraSpeedBus.Abstractions.Message; | |
| namespace UltraSpeedBus.Abstractions.Transport; |
Copilot
AI
Nov 18, 2025
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.
The MessageEnvelope class is defined in ITransportProducer.cs, but should be in its own file MessageEnvelope.cs in the Message folder for better code organization and maintainability.
Copilot
AI
Nov 18, 2025
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.
Spelling error: 'envolope' should be 'envelope'.
| Task SendAsync(string queue, MessageEnvelope envelop, CancellationToken cancellationToken = default); | |
| Task PublishAsync(string topic, MessageEnvelope envelop, CancellationToken cancellationToken = default); | |
| Task SendAsync(string queue, MessageEnvelope envelope, CancellationToken cancellationToken = default); | |
| Task PublishAsync(string topic, MessageEnvelope envelope, CancellationToken cancellationToken = default); |
Copilot
AI
Nov 18, 2025
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.
Spelling error: 'envolope' should be 'envelope'.
| Task SendAsync(string queue, MessageEnvelope envelop, CancellationToken cancellationToken = default); | |
| Task PublishAsync(string topic, MessageEnvelope envelop, CancellationToken cancellationToken = default); | |
| Task SendAsync(string queue, MessageEnvelope envelope, CancellationToken cancellationToken = default); | |
| Task PublishAsync(string topic, MessageEnvelope envelope, CancellationToken cancellationToken = default); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
The
IQueryHandlerinterface hasHandleAsyncreturningTaskbut it should returnTask<TResult>since queries are expected to return results.