Exemple #1
0
 void HandleRebuildResult(ReplayResult result, RebuildProjectionVersion @event)
 {
     if (result.IsSuccess)
     {
         var finalize = new FinalizeProjectionVersionRequest(@event.ProjectionVersionRequest.Id, @event.ProjectionVersionRequest.Version);
         commandPublisher.Publish(finalize);
     }
     else if (result.ShouldRetry)
     {
         RequestTimeout(new RebuildProjectionVersion(@event.ProjectionVersionRequest, DateTime.UtcNow.AddSeconds(30)));
     }
     else
     {
         log.Error(() => result.Error);
         if (result.IsTimeout)
         {
             var timedout = new TimeoutProjectionVersionRequest(@event.ProjectionVersionRequest.Id, @event.ProjectionVersionRequest.Version, @event.ProjectionVersionRequest.Timebox);
             commandPublisher.Publish(timedout);
         }
         else
         {
             var cancel = new CancelProjectionVersionRequest(@event.ProjectionVersionRequest.Id, @event.ProjectionVersionRequest.Version, result.Error);
             commandPublisher.Publish(cancel);
         }
     }
 }
Exemple #2
0
        public async Task HandleAsync(CreateNewProjectionVersion sagaTimeout)
        {
            RebuildProjection_Job job    = jobFactory.CreateJob(sagaTimeout.ProjectionVersionRequest.Version, sagaTimeout.ProjectionVersionRequest.Timebox);
            JobExecutionStatus    result = await jobRunner.ExecuteAsync(job).ConfigureAwait(false);

            logger.Debug(() => "Replay projection version {@cronus_projection_rebuild}", result);

            if (result == JobExecutionStatus.Running)
            {
                RequestTimeout(new CreateNewProjectionVersion(sagaTimeout.ProjectionVersionRequest, DateTime.UtcNow.AddSeconds(30)));
            }
            else if (result == JobExecutionStatus.Failed)
            {
                var cancel = new CancelProjectionVersionRequest(sagaTimeout.ProjectionVersionRequest.Id, sagaTimeout.ProjectionVersionRequest.Version, "Failed");
                commandPublisher.Publish(cancel);
            }
            else if (result == JobExecutionStatus.Completed)
            {
                var finalize = new FinalizeProjectionVersionRequest(sagaTimeout.ProjectionVersionRequest.Id, sagaTimeout.ProjectionVersionRequest.Version);
                commandPublisher.Publish(finalize);
            }
        }
 public Task HandleAsync(CancelProjectionVersionRequest command)
 {
     return(UpdateAsync(command.Id, ar => ar.CancelVersionRequest(command.Version, command.Reason)));
 }