public async Task Handle(ConnectedProjectionCommand?command) { if (command == null) { _logger.LogWarning("Skipping null Command"); return; } switch (command) { case SubscriptionCommand subscriptionCommand: await _subscriptionRunner.HandleSubscriptionCommand(subscriptionCommand); return; case CatchUpCommand catchUpCommand: _catchUpRunner.HandleCatchUpCommand(catchUpCommand); return; } _logger.LogTrace("Handling {Command}", command); switch (command) { case Start start: _commandBus.Queue(new Subscribe(start.Projection)); break; case StartAll _: _commandBus.Queue <SubscribeAll>(); break; case Stop stop: _commandBus.Queue(new StopCatchUp(stop.Projection)); _commandBus.Queue(new Unsubscribe(stop.Projection)); break; case StopAll _: _commandBus.Queue <StopAllCatchUps>(); _commandBus.Queue <UnsubscribeAll>(); break; case Restart restart: await Task.Delay(restart.After); _commandBus.Queue(new Start(restart.Projection)); break; default: _logger.LogError("No handler defined for {Command}", command); break; } }
public async Task Handle(ConnectedProjectionCommand command) { switch (command) { case SubscriptionCommand subscriptionCommand: await _subscriptionRunner.HandleSubscriptionCommand(subscriptionCommand); return; case CatchUpCommand catchUpCommand: _catchUpRunner.HandleCatchUpCommand(catchUpCommand); return; } _logger.LogTrace("Handling {Command}", command); switch (command) { case Start start: _commandBus.Queue(new Subscribe(start.ProjectionName)); break; case StartAll _: _commandBus.Queue <SubscribeAll>(); break; case Stop stop: _commandBus.Queue(new StopCatchUp(stop.ProjectionName)); _commandBus.Queue(new Unsubscribe(stop.ProjectionName)); break; case StopAll _: _commandBus.Queue <StopAllCatchUps>(); _commandBus.Queue <UnsubscribeAll>(); break; default: _logger.LogError("No handler defined for {Command}", command); break; } }