-
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
Conversation
…ssageEnvelope interfaces
…ITransportConsumer, and ITransportProducer interfaces
…sageSerializer, MessageEnvelope, and MessageFactory
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.
Pull Request Overview
This PR refactors the messaging framework by removing unused interfaces and introducing new abstractions for command/query handling and transport operations. The changes streamline the codebase by removing saga-related interfaces, context abstractions, and serialization interfaces while adding new handler patterns and transport layer abstractions.
- Introduces
ICommandHandler,IEventHandler,IQueryHandlerinterfaces for CQRS pattern support - Adds new transport abstractions (
ITransport,ITransportProducer,ITransportConsumer) with support for multiple messaging patterns - Removes unused interfaces for sagas, contexts, scheduled messages, and serialization
- Enhances documentation for message marker interfaces (
ICommand,IEvent,IQuery)
Reviewed Changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| UltraSpeedBus.Abstractions/Message/ICommandHandler.cs | New handler interface for processing commands |
| UltraSpeedBus.Abstractions/Message/IEventHandler.cs | New handler interface for processing events |
| UltraSpeedBus.Abstractions/Message/IQueryHandler.cs | New handler interface for processing queries (has bug with return type) |
| UltraSpeedBus.Abstractions/Message/ICommand.cs | Added documentation to command marker interface |
| UltraSpeedBus.Abstractions/Message/IEvent.cs | Added documentation to event marker interface |
| UltraSpeedBus.Abstractions/Message/IQuery.cs | New query marker interface with generic result type |
| UltraSpeedBus.Abstractions/Message/IMessage.cs | Cleaned up and documented base message interface, removed unused interfaces |
| UltraSpeedBus.Abstractions/Transport/ITransport.cs | New factory interface for creating producers and consumers |
| UltraSpeedBus.Abstractions/Transport/ITransportProducer.cs | Refactored producer interface with queue/topic parameters, includes MessageEnvelope definition |
| UltraSpeedBus.Abstractions/Transport/ITransportConsumer.cs | Refactored consumer interface with renamed methods and empty ConsumerTransportContext |
| UltraSpeedBus.Abstractions/Transport/ITransportTopology.cs | Removed unused topology management interface |
| UltraSpeedBus.Abstractions/Transport/ConsumerTransportContext.cs | Deleted complete implementation (replaced with empty stub) |
| UltraSpeedBus.Abstractions/Message/MessageEnvelope.cs | Deleted rich envelope implementation (replaced with simplified version) |
| UltraSpeedBus.Abstractions/Message/IScheduledMessage.cs | Removed scheduled message interface |
| UltraSpeedBus.Abstractions/Message/ICorrelatedMessage.cs | Removed correlation interface |
| UltraSpeedBus.Abstractions/Contexts/* | Removed all context-related interfaces |
| UltraSpeedBus.Abstractions/Sagas/* | Removed all saga-related interfaces |
| UltraSpeedBus.Abstractions/Serializer/IMessageSerializer.cs | Removed serializer interface |
| UltraSpeedBus.Abstractions/obj/* | Removed build artifacts and generated files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Task SendAsync(string queue, MessageEnvelope envelop, CancellationToken cancellationToken = default); | ||
| Task PublishAsync(string topic, MessageEnvelope envelop, 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); |
| Task SendAsync(string queue, MessageEnvelope envelop, CancellationToken cancellationToken = default); | ||
| Task PublishAsync(string topic, MessageEnvelope envelop, 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); |
| @@ -1,7 +1,23 @@ | |||
| namespace UltraSpeedBus.Abstractions.Transport; | |||
| namespace UltraSpeedBus.Abstractions.Message; | |||
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, ITransportConsumer classes/interfaces are declared in the UltraSpeedBus.Abstractions.Message namespace but are located in the Transport folder. These should use the UltraSpeedBus.Abstractions.Transport namespace for consistency with their file location.
| namespace UltraSpeedBus.Abstractions.Message; | |
| namespace UltraSpeedBus.Abstractions.Transport; |
| @@ -0,0 +1,7 @@ | |||
| namespace UltraSpeedBus.Abstractions.Message; | |||
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 ITransport interface is declared in the UltraSpeedBus.Abstractions.Message namespace but is located in the Transport folder. This should use the UltraSpeedBus.Abstractions.Transport namespace for consistency with its file location.
| namespace UltraSpeedBus.Abstractions.Message; | |
| namespace UltraSpeedBus.Abstractions.Transport; |
| } | ||
|
|
||
| public class ConsumerTransportContext | ||
| { |
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(); |
| public interface IQueryHandler<TQuery, TResult> | ||
| where TQuery : IQuery<TResult> | ||
| { | ||
| Task HandleAsync(TQuery query, CancellationToken cancellationToken); |
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 IQueryHandler interface has HandleAsync returning Task but it should return Task<TResult> since queries are expected to return results.
| Task HandleAsync(TQuery query, CancellationToken cancellationToken); | |
| Task<TResult> HandleAsync(TQuery query, CancellationToken cancellationToken); |
| @@ -1,12 +1,20 @@ | |||
| using UltraSpeedBus.Abstractions.Message; | |||
| namespace UltraSpeedBus.Abstractions.Message; | |||
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, ITransportProducer, ITransportConsumer, ConsumerTransportContext, and ITransport classes/interfaces are declared in the UltraSpeedBus.Abstractions.Message namespace but are located in the Transport folder. These should use the UltraSpeedBus.Abstractions.Transport namespace for consistency with their file location.
| namespace UltraSpeedBus.Abstractions.Message; | |
| namespace UltraSpeedBus.Abstractions.Transport; |
| public class MessageEnvelope | ||
| { | ||
| public Guid MessageId { get; init; } | ||
| public string MessageType { get; init; } = null!; | ||
| public byte[] Payload { get; init; } = null!; | ||
| } |
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.
| public class ConsumerTransportContext | ||
| { | ||
| } No newline at end of file |
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.
Refactor existing message handling interfaces by removing unused ones and enhancing documentation. Introduce new interfaces for command and query handling, along with transport abstractions for producers and consumers. This update improves clarity and extensibility in the messaging framework.