Пример #1
0
        public async Task StartShard(IAsyncProjectionShard shard, CancellationToken cancellationToken)
        {
            if (!_hasStarted)
            {
                StartNode();
            }

            // Don't duplicate the shard
            if (_agents.ContainsKey(shard.Name.Identity))
            {
                return;
            }

            await TryAction(null, async() =>
            {
                try
                {
                    var agent    = new ProjectionAgent(_store, shard, _logger, cancellationToken);
                    var position = await agent.Start(this);

                    Tracker.Publish(new ShardState(shard.Name, position)
                    {
                        Action = ShardAction.Started
                    });

                    _agents[shard.Name.Identity] = agent;
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Error when trying to start projection shard '{ShardName}'", shard.Name.Identity);
                    throw new ShardStartException(shard.Name, e);
                }
            }, cancellationToken);
        }
Пример #2
0
        public async Task StartShard(IAsyncProjectionShard shard)
        {
            if (!_hasStarted)
            {
                StartNode();
            }

            // TODO -- log the start, or error if it fails
            var agent    = new ProjectionAgent(_store, shard, _logger);
            var position = await agent.Start(Tracker);

            Tracker.Publish(new ShardState(shard.ProjectionOrShardName, position)
            {
                Action = ShardAction.Started
            });

            _agents[shard.ProjectionOrShardName] = agent;
        }