Skip to content

Conversation

@elyosemite
Copy link
Owner

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.

…sageSerializer, MessageEnvelope, and MessageFactory
Copy link

Copilot AI left a 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, IQueryHandler interfaces 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.

Comment on lines +18 to +19
Task SendAsync(string queue, MessageEnvelope envelop, CancellationToken cancellationToken = default);
Task PublishAsync(string topic, MessageEnvelope envelop, CancellationToken cancellationToken = default);
Copy link

Copilot AI Nov 18, 2025

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'.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +18 to +19
Task SendAsync(string queue, MessageEnvelope envelop, CancellationToken cancellationToken = default);
Task PublishAsync(string topic, MessageEnvelope envelop, CancellationToken cancellationToken = default);
Copy link

Copilot AI Nov 18, 2025

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'.

Suggested change
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 uses AI. Check for mistakes.
@@ -1,7 +1,23 @@
namespace UltraSpeedBus.Abstractions.Transport;
namespace UltraSpeedBus.Abstractions.Message;
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
namespace UltraSpeedBus.Abstractions.Message;
namespace UltraSpeedBus.Abstractions.Transport;

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,7 @@
namespace UltraSpeedBus.Abstractions.Message;
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
namespace UltraSpeedBus.Abstractions.Message;
namespace UltraSpeedBus.Abstractions.Transport;

Copilot uses AI. Check for mistakes.
}

public class ConsumerTransportContext
{
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
{
{
/// <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 uses AI. Check for mistakes.
public interface IQueryHandler<TQuery, TResult>
where TQuery : IQuery<TResult>
{
Task HandleAsync(TQuery query, CancellationToken cancellationToken);
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
Task HandleAsync(TQuery query, CancellationToken cancellationToken);
Task<TResult> HandleAsync(TQuery query, CancellationToken cancellationToken);

Copilot uses AI. Check for mistakes.
@@ -1,12 +1,20 @@
using UltraSpeedBus.Abstractions.Message;
namespace UltraSpeedBus.Abstractions.Message;
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
namespace UltraSpeedBus.Abstractions.Message;
namespace UltraSpeedBus.Abstractions.Transport;

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +8
public class MessageEnvelope
{
public Guid MessageId { get; init; }
public string MessageType { get; init; } = null!;
public byte[] Payload { get; init; } = null!;
}
Copy link

Copilot AI Nov 18, 2025

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 uses AI. Check for mistakes.
Comment on lines +21 to +23
public class ConsumerTransportContext
{
} No newline at end of file
Copy link

Copilot AI Nov 18, 2025

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.

Copilot uses AI. Check for mistakes.
@elyosemite elyosemite merged commit a5bfbdc into develop Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants