Beispiel #1
0
        public async Task <Unit> Handle(CreateOrder command, CancellationToken cancellationToken)
        {
            // DO WORK HERE
            await _coordinator.ProcessAsync(command, SagaContext.Empty);

            return(Unit.Value);
        }
Beispiel #2
0
        public void Handle(Message message)
        {
            var sagaContext = SagaContext.Empty;

            switch (message)
            {
            case StartCreatingExperimentWithMethods m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case ExperimentCreated m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case ExperimentCreationFailed m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case MethodsCreated m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case MethodsCreationFailed m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case MethodsAddedToExperiment m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case MethodsAdditionToExperimentFailed m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case ExperimentAddedToMethods m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case ExperimentAdditionToMethodsFailed m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;

            case ExperimentWithMethodsCreationFailed m: _sagaCoordinator.ProcessAsync(m, sagaContext); break;
            }
        }
Beispiel #3
0
        public async Task <Unit> Handle(CreateOrder command, CancellationToken cancellationToken)
        {
            await _coordinator.ProcessAsync(command, SagaContext.Empty);

            // once every thing is processed in the handler, commit changes to DB.
            // This can be moved else where depending on the user needs.
            await SagaUnitOfWork.CommitAsync();

            return(Unit.Value);
        }
        public async Task HandleAsync(T @event, ICorrelationContext context)
        {
            if (@event.BelongsToSaga())
            {
                var sagaContext = SagaContext.FromCorrelationContext(context);
                await _sagaCoordinator.ProcessAsync(@event, sagaContext);
            }

            switch (@event)
            {
            case IRejectedEvent rejectedEvent:
                await _operationsStorage.SetAsync(context.Id, context.UserId,
                                                  context.Name, OperationState.Rejected, context.Resource,
                                                  rejectedEvent.Code, rejectedEvent.Reason);

                await _operationPublisher.RejectAsync(context,
                                                      rejectedEvent.Code, rejectedEvent.Reason);

                return;

            case IEvent _:
                await _operationsStorage.SetAsync(context.Id, context.UserId,
                                                  context.Name, OperationState.Completed, context.Resource);

                await _operationPublisher.CompleteAsync(context);

                return;
            }
        }
Beispiel #5
0
 public async Task HandleAsync(TEvent @event, ICorrelationContext context)
 {
     if (@event.BelongsToSaga())
     {
         var sagaContext = SagaContext.CreateFromCorrelationContext(context);
         await sagaCoordinator.ProcessAsync(@event, sagaContext);
     }
 }
Beispiel #6
0
        public async Task HandleAsync(T command, ICorrelationContext context)
        {
            if (!command.BelongsToSaga())
            {
                return;
            }

            var sagaContext = SagaContext.FromCorrelationContext(context);
            await _sagaCoordinator.ProcessAsync(command, sagaContext);
        }
Beispiel #7
0
 public async Task PublishAsync <TEvent>(TEvent @event, ICorrelationContext context) where TEvent : IEvent
 {
     if (@event.BelongsToSaga())
     {
         var sagaContext = SagaContext.CreateFromCorrelationContext(context);
         await sagaCoordinator.ProcessAsync(@event, sagaContext);
     }
     else
     {
         await busClient.PublishAsync(@event, ctx => ctx.UseMessageContext(context));
     }
 }
Beispiel #8
0
        public async Task HandleAsync(T command, ICorrelationContext context)
        {
            if (command.IsProcessable())
            {
                var sagaContext = SagaContext.FromCorrelationContext(context);
                await _sagaCoordinator.ProcessAsync(command, sagaContext);

                return;
            }

            if (await _operationsStorage.TrySetAsync(context.Id, context.UserId,
                                                     context.Name, OperationState.Pending, context.Resource, string.Empty))
            {
                await _operationPublisher.PendingAsync(context);
            }
        }
 public async Task HandleAsync(T @event, ICorrelationContext context)
 {
     var sagaContext = Sagas.SagaContext.FromCorrelationContext(context);
     await _sagaCoordinator.ProcessAsync(@event, sagaContext);
 }
Beispiel #10
0
 private Task HandleSagaAsync <T>(T @event) where T : class, IEvent
 => _coordinator.ProcessAsync(@event, SagaContext.Empty);
Beispiel #11
0
 public Task HandleAsync(MakeOrder command)
 => _coordinator.ProcessAsync(command, SagaContext.Empty);