// TODO -- use IAsyncDisposable public async Task Stop() { _cancellationSource.Cancel(); _commandBlock.Complete(); await _commandBlock.Completion; _loader.Complete(); await _loader.Completion; _hopper.Complete(); await _hopper.Completion; await _projectionShard.Stop(); _subscription.Dispose(); }
public async Task Stop(Exception ex = null) { _logger.LogInformation("Stopping projection shard '{ShardName}'", _projectionShard.Name); _cancellationSource?.Cancel(); _commandBlock.Complete(); await _commandBlock.Completion; _loader.Complete(); await _loader.Completion; _hopper.Complete(); await _hopper.Completion; try { await _projectionShard.Stop(); } catch (Exception e) { _logger.LogError(e, "Error trying to stop shard '{ShardName}'", _projectionShard.Name); } _subscription.Dispose(); _fetcher.Dispose(); _subscription = null; _fetcher = null; _commandBlock = null; _hopper = null; _loader = null; _logger.LogInformation("Stopped projection shard '{ShardName}'", _projectionShard.Name); _tracker.Publish(new ShardState(_projectionShard.Name, Position) { Action = ShardAction.Stopped, Exception = null }); }