public async Task ExecuteBatch(ProjectionUpdateBatch batch) { if (_cancellation.IsCancellationRequested || batch == null) { return; } await batch.Queue.Completion.ConfigureAwait(false); if (_cancellation.IsCancellationRequested) { return; } var session = (DocumentSessionBase)_store.OpenSession(_sessionOptions); await using (session.ConfigureAwait(false)) { try { await session.ExecuteBatchAsync(batch, _cancellation).ConfigureAwait(false); _logger.LogInformation("Shard '{ProjectionShardIdentity}': Executed updates for {Range}", ProjectionShardIdentity, batch.Range); } catch (Exception e) { if (!_cancellation.IsCancellationRequested) { _logger.LogError(e, "Failure in shard '{ProjectionShardIdentity}' trying to execute an update batch for {Range}", ProjectionShardIdentity, batch.Range); throw; } } finally { batch.Dispose(); } } batch.Dispose(); if (_cancellation.IsCancellationRequested) { return; } Position = batch.Range.SequenceCeiling; _tracker.Publish(new ShardState(ShardName, batch.Range.SequenceCeiling) { Action = ShardAction.Updated }); _commandBlock.Post(Command.Completed(batch.Range)); }
public async Task ExecuteBatch(ProjectionUpdateBatch batch) { await batch.Queue.Completion; using (var session = (DocumentSessionBase)_store.LightweightSession()) { try { await session.ExecuteBatchAsync(batch, _cancellationSource.Token); _logger.LogInformation($"Shard '{ProjectionOrShardName}': Executed updates for {batch.Range}"); } catch (Exception e) { _logger.LogError(e, $"Failure in shard '{ProjectionOrShardName}' trying to execute an update batch for {batch.Range}"); // TODO -- error handling throw; } } batch.Dispose(); Position = batch.Range.SequenceCeiling; _tracker.Publish(new ShardState(ProjectionOrShardName, batch.Range.SequenceCeiling)); _commandBlock.Post(Command.Completed(batch.Range)); }
public async Task ExecuteBatch(ProjectionUpdateBatch batch) { if (_cancellation.IsCancellationRequested) return; await batch.Queue.Completion; if (_cancellation.IsCancellationRequested) return; await using (var session = (DocumentSessionBase)_store.LightweightSession()) { try { await session.ExecuteBatchAsync(batch, _cancellation); _logger.LogInformation("Shard '{ShardName}': Executed updates for {Range}", ShardName, batch.Range); } catch (Exception e) { if (!_cancellation.IsCancellationRequested) { _logger.LogError(e, "Failure in shard '{ShardName}' trying to execute an update batch for {Range}", ShardName, batch.Range); throw; } } finally { batch.Dispose(); } } batch.Dispose(); if (_cancellation.IsCancellationRequested) return; Position = batch.Range.SequenceCeiling; _tracker.Publish(new ShardState(ShardName, batch.Range.SequenceCeiling)); _commandBlock.Post(Command.Completed(batch.Range)); }