コード例 #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);
         }
     }
 }
コード例 #2
0
ファイル: ProjectionBuilder.cs プロジェクト: Elders/Cronus
        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);
            }
        }
コード例 #3
0
        public void Handle(RebuildProjectionVersion @event)
        {
            if (Player.RebuildIndex() == false)
            {
                RequestTimeout(new RebuildProjectionVersion(@event.ProjectionVersionRequest, DateTime.UtcNow.AddSeconds(30)));
                return;
            }
            var rebuildUntil = @event.ProjectionVersionRequest.Timebox.RebuildFinishUntil;

            if (rebuildUntil < DateTime.UtcNow)
            {
                return;
            }

            var theType           = @event.ProjectionVersionRequest.ProjectionVersion.ProjectionName.GetTypeByContract();
            var rebuildTimesOutAt = @event.ProjectionVersionRequest.Timebox.RebuildFinishUntil;

            if (Player.Rebuild(theType, @event.ProjectionVersionRequest.ProjectionVersion, rebuildTimesOutAt))
            {
                var command = new FinalizeProjectionVersionRequest(@event.ProjectionVersionRequest.Id, @event.ProjectionVersionRequest.ProjectionVersion);
                CommandPublisher.Publish(command);
            }
        }
コード例 #4
0
 public Task HandleAsync(FinalizeProjectionVersionRequest command)
 {
     return(UpdateAsync(command.Id, ar => ar.FinalizeVersionRequest(command.Version)));
 }
コード例 #5
0
 public void Handle(FinalizeProjectionVersionRequest command)
 {
     Update(command.Id, ar => ar.FinalizeVersionRequest(command.Version));
 }