-
Notifications
You must be signed in to change notification settings - Fork 0
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
CRS 2 Design #3
Comments
The question is: should we consider the result of a command or only its impact on the system? |
There is one constraint: WebSocketEvents can only be published by the CRS endpoint, which holds the WebSocket connection. |
The kernel supports now both command handlers with and without results, and event handlers. public interface ICommandHandler<T> : ICommandHandler
{
/// <summary>
/// Handles a request with the given <see cref="ICommandContext"/>.
/// </summary>
/// <remarks>
/// If the request is like a Command, the context is the one of this command.
/// If the request is like an Event, the context is the original command that raises this event.</remarks>
/// <param name="request">The request to handle.</param>
/// <param name="context">The command context. See remarks.</param>
/// <returns></returns>
Task HandleAsync( T request, ICommandContext context );
}
public interface ICommandHandler<T, TResult> : ICommandHandlerWithResult
{
/// <summary>
/// Handles a request with the given <see cref="ICommandContext"/>.
/// </summary>
/// <remarks>
/// If the request is like a Command, the context is the one of this command.
/// If the request is like an Event, the context is the original command that raises this event.</remarks>
/// <param name="request">The request to handle.</param>
/// <param name="context">The command context. See remarks.</param>
/// <returns></returns>
Task<TResult> HandleAsync( T request, ICommandContext context );
}
public interface IEventHandler<T>: IEventHandler
{
Task HandleAsync( T request, ICommandContext context );
} |
Main interface ICommandHandler is renamed to IRequestHandler (to support commands and events...) and does no longer returns a result (but Task obviously).
This enforces to treat impacts of a command like pure events.
What are your thoughts about that?
Is it really what we want?
Should CRS still offers a way to return "synchronous" results of a command or should we left this usage for simple REST-like interactions ?
The text was updated successfully, but these errors were encountered: