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); } } }
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); } }
public void Handle(RebuildProjectionVersion @event) { ReplayResult result = projectionPlayer.Rebuild(@event.ProjectionVersionRequest.Version, @event.ProjectionVersionRequest.Timebox.RebuildFinishUntil); HandleRebuildResult(result, @event); }