Skip to content

2.0.0-beta

Pre-release
Pre-release
Compare
Choose a tag to compare
@meinsiedler meinsiedler released this 13 Dec 10:46
· 48 commits to master since this release

Breaking Changes

  • All packages now target netstandard2.1.
  • It is now needed that the two decorators softaware.Cqs.SimpleInjector.PublicCommandHandlerDecorator and softaware.Cqs.SimpleInjector.PublicQueryHandlerDecorator are registered as last decorator in the chain when using softaware.Cqs.SimpleInjector.DynamicCommandProcessor and softaware.Cqs.SimpleInjector.DynamicQueryProcessor. This is needed so that the dynamic processors can call the correct overload of the HandleAsync method. Secondly this is needed when trying to call an internal decorator or an internal handler. If these two decorators are not registered, an exception will be thrown when trying to call ExecuteAsync on either the ICommandProcessor or IQueryProcessor. See here for more details.
  • The package softaware.Cqs.EntityFramework is deprecated and no longer supported. It has been removed from this release.

New Features

  • It is now possible to pass a CancellationToken when executing command handlers and query handlers. So it is now easily possible to cancel the execution of commands and queries. To use the cancellable version, implement the HandleAsync(command, token) default interface method and delegate to this implementation in the HandleAsync(command) method:

      internal class LongRunningCommandHandler : ICommandHandler<LongRunningCommand>
      {
          public Task HandleAsync(LongRunningCommand command)
          {
              return this.HandleAsync(command, default);
          }
    
          public async Task HandleAsync(LongRunningCommand command, CancellationToken cancellationToken)
          {
              await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken);
          }
      }

    Note: For this to work, all existing Decorators must override the HandleAsync(command, token) method and pass the cancellationToken to the inner handlers.