Exemple #1
0
        private async Task processRange(T group)
        {
            if (_token.IsCancellationRequested)
            {
                return;
            }

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug($"Shard '{ProjectionOrShardName}': Starting to build an update batch for {group}");
            }

            var batch = _updater.StartNewBatch(group.Range);

            await configureUpdateBatch(batch, group, _token);

            batch.Queue.Complete();
            await batch.Queue.Completion;

            await _updater.ExecuteBatch(batch);

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug($"Shard '{ProjectionOrShardName}': Configured batch {group}");
            }

            group.Dispose();
        }
Exemple #2
0
        private async Task processRange(T group)
        {
            if (_token.IsCancellationRequested)
            {
                return;
            }

            await _updater.TryAction(async() =>
            {
                try
                {
                    group.Reset();

                    if (_logger.IsEnabled(LogLevel.Debug))
                    {
                        _logger.LogDebug("Shard '{ShardName}': Starting to build an update batch for {Group}", Name, group);
                    }

                    if (_token.IsCancellationRequested)
                    {
                        return;
                    }

                    var batch = _updater.StartNewBatch(@group.Range, _token);

                    await configureUpdateBatch(batch, group, _token);

                    if (_token.IsCancellationRequested)
                    {
                        return;
                    }

                    batch.Queue.Complete();
                    await batch.Queue.Completion;

                    if (_token.IsCancellationRequested)
                    {
                        return;
                    }

                    await _updater.ExecuteBatch(batch);

                    if (_logger.IsEnabled(LogLevel.Debug))
                    {
                        _logger.LogDebug("Shard '{ShardName}': Configured batch {Group}", Name, group);
                    }

                    group.Dispose();
                }
                catch (Exception e)
                {
                    if (!_token.IsCancellationRequested)
                    {
                        _logger.LogError(e, "Failure while trying to process updates for event range {EventRange} for projection shard '{ShardName}'", group, Name);
                        throw;
                    }
                }
            }, _token);
        }