private async Task Handle(CreateSnapshotCommand command, IEventPublisher publisher) { //deduplication is inside _snapshotService.MakeTradingDataSnapshot try { await _snapshotService.MakeTradingDataSnapshot(command.TradingDay, command.OperationId); publisher.PublishEvent(new SnapshotCreatedEvent { OperationId = command.OperationId, CreationTime = _dateService.Now(), }); } catch (Exception exception) { await _log.WriteErrorAsync(nameof(EodCommandsHandler), nameof(CreateSnapshotCommand), exception); publisher.PublishEvent(new SnapshotCreationFailedEvent { OperationId = command.OperationId, CreationTime = _dateService.Now(), FailReason = exception.Message, }); } }
public static QueryAsyncJobResultResponse CreateSnapshots(string volumeId) { var cmd = new CreateSnapshotCommand(volumeId); cmd.ExecuteCommand(); Thread.Sleep(ConfigurationHelper.CommandExecutionDelayInSeconds); return(cmd.QueryAsyncJobResultResponse); }
public async Task Post_ReturnsForbiddenIFNoConfiguratorClaim() { var command = new CreateSnapshotCommand { Name = "1.0.0", ClientId = "3E37AC18-A00F-47A5-B84E-C29E0823F6D8" }; var context = TestHttpContextBuilder.CreateForPath($"/") .WithPost() .WithJsonBody <CreateSnapshotCommand>(command) .WithClaims() .TestContext; var commandResult = CommandResult.Success(); await target.Handle(context, options); commandBus.Verify(cb => cb.SubmitAsync <CreateSnapshotCommand>(It.IsAny <CreateSnapshotCommand>()), Times.Never); httpResponseFactory.Verify(f => f.BuildStatusResponse(context, 403)); }
public async Task Post_RaisesCommand() { var command = new CreateSnapshotCommand { Name = "1.0.0", ClientId = "3E37AC18-A00F-47A5-B84E-C29E0823F6D8" }; var context = TestHttpContextBuilder.CreateForPath($"/") .WithPost() .WithJsonBody <CreateSnapshotCommand>(command) .WithClaims(configuratorClaim) .TestContext; var commandResult = CommandResult.Success(); commandBus.Setup(cb => cb.SubmitAsync <CreateSnapshotCommand>(It.Is <CreateSnapshotCommand>(s => s.Name == command.Name && s.ClientId == command.ClientId))) .ReturnsAsync(commandResult); await target.Handle(context, options); httpResponseFactory.Verify(f => f.BuildResponseFromCommandResult(context, commandResult)); }