Example #1
0
        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
            });
        }
Example #2
0
        public Task Stop(Exception ex = null)
        {
            _isStopping = true;

            _logger.LogInformation("Stopping projection shard '{ShardName}'", _projectionShard.Name);

            _cancellationSource?.Cancel();

            _commandBlock.Complete();
            _loader.Complete();
            _grouping.Complete();
            _building.Complete();

            _subscription.Dispose();

            _fetcher.Dispose();

            _subscription = null;
            _fetcher = null;
            _commandBlock = null;
            _grouping = null;
            _loader = null;
            _building = null;

            _logger.LogInformation("Stopped projection shard '{ShardName}'", _projectionShard.Name);

            _tracker.Publish(new ShardState(_projectionShard.Name, Position)
            {
                Action = ShardAction.Stopped,
                Exception = ex
            });

            _isStopping = false;

            return Task.CompletedTask;
        }