v0.50.3124
-
New: While EventFlow tries to limit the about of painful API changes, the
introduction of execution/command results are considered a necessary step
towards as better API.Commands and command handlers have been updated to support execution
results. Execution results is meant to be an alternative to throwing domain
exceptions to do application flow. In short, before you were required to
throw an exception if you wanted to abort execution and "return" a failure
message.The introduction of execution results changes this, as it allows
returning a failed result that is passed all the way back to the command
publisher. Execution results are generic and can thus contain e.g. any
validation results that a UI might need. TheICommandBus.PublishAsync
signature has changed to reflect this.from
Task<ISourceId> PublishAsync<TAggregate, TIdentity, TSourceIdentity>( ICommand<TAggregate, TIdentity, TSourceIdentity> command) where TAggregate : IAggregateRoot<TIdentity> where TIdentity : IIdentity where TSourceIdentity : ISourceId
to
Task<TExecutionResult> PublishAsync<TAggregate, TIdentity, TExecutionResult>( ICommand<TAggregate, TIdentity, TExecutionResult> command, CancellationToken cancellationToken) where TAggregate : IAggregateRoot<TIdentity> where TIdentity : IIdentity where TExecutionResult : IExecutionResult
Command handler signature has changed from
Task ExecuteAsync( TAggregate aggregate, TCommand command, CancellationToken cancellationToken);
to
Task<TExecutionResult> ExecuteCommandAsync( TAggregate aggregate, TCommand command, CancellationToken cancellationToken)
Migrating to the new structure should be seamless if your current code base
inherits its command handlers from the providedCommandHandler<,,>
base
class. -
Breaking: Source IDs on commands have been reworked to "make room" for
execution results on commands. The generic parameter fromICommand<,,>
andICommandHandler<,,,>
has been removed in favor of the new execution
results.ICommand.SourceId
is now of typeISourceId
instead of using
the generic type and theICommandBus.PublishAsync
no longer returns
Task<ISourceId>
To get code that behaves similar to the previous version, simply take the
ISourceId
from the command, i.e., instead of thisvar sourceId = await commandBus.PublishAsync(command);
write this
await commandBus.PublishAsync(command); var sourceId = command.SourceId;
(
CancellationToken
and.ConfigureAwait(false)
omitted fromt he above) -
Breaking: Upgraded NuGet dependency on
RabbitMQ.Client
from>= 4.1.3
to>= 5.0.1