Exemplo n.º 1
0
        public override async Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                                        EventRangeGroup eventRangeGroup)
        {
            var eventGroupTasks = Groups
                                  .Select(x => x.Start(shardAgent, batch.Queue, _runtime, _store, this))
                                  .ToArray();

            await Task.WhenAll(eventGroupTasks).ConfigureAwait(false);

            if (Exception != null)
            {
                ExceptionDispatchInfo.Capture(Exception).Throw();
            }
        }
Exemplo n.º 2
0
        public override async Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                                        EventRangeGroup eventRangeGroup)
        {
            foreach (var @group in Groups)
            {
                @group.Start(shardAgent, batch.Queue, _runtime, _store, this);
            }

            await Task.WhenAll(Groups.Select(x => x.Complete()).ToArray());

            if (Exception != null)
            {
                ExceptionDispatchInfo.Capture(Exception).Throw();
            }
        }
Exemplo n.º 3
0
        public override async Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch)
        {
#if NET6_0_OR_GREATER
            await Parallel.ForEachAsync(Groups, CancellationToken.None,
                                        async (group, _) =>
                                        await group.Start(shardAgent, batch, _runtime, _store, this).ConfigureAwait(false))
            .ConfigureAwait(false);
#else
            var eventGroupTasks = Groups
                                  .Select(x => x.Start(shardAgent, batch, _runtime, _store, this))
                                  .ToArray();

            await Task.WhenAll(eventGroupTasks).ConfigureAwait(false);
#endif


            if (Exception != null)
            {
                ExceptionDispatchInfo.Capture(Exception).Throw();
            }
        }
Exemplo n.º 4
0
        internal async Task Start(IShardAgent shardAgent, ProjectionUpdateBatch updateBatch,
                                  IAggregationRuntime <TDoc, TId> runtime,
                                  DocumentStore store, EventRangeGroup parent)
        {
            _session = new ProjectionDocumentSession(store, updateBatch, new SessionOptions {
                Tracking = DocumentTracking.None, Tenant = Tenant
            });

            _builder = new ActionBlock <EventSlice <TDoc, TId> >(async slice =>
            {
                if (parent.Cancellation.IsCancellationRequested)
                {
                    return;
                }

                await shardAgent.TryAction(async() =>
                {
                    await runtime.ApplyChangesAsync(_session, slice, parent.Cancellation, ProjectionLifecycle.Async).ConfigureAwait(false);
                }, parent.Cancellation, @group: parent, logException: (l, e) =>
                {
                    l.LogError(e, "Failure trying to build a storage operation to update {DocumentType} with {Id}", typeof(TDoc).FullNameInCode(), slice.Id);
                }, actionMode: GroupActionMode.Child).ConfigureAwait(false);
            }, new ExecutionDataflowBlockOptions
            {
                CancellationToken = parent.Cancellation,
            });

            await processEventSlices(shardAgent, runtime, store, parent.Cancellation).ConfigureAwait(false);

            var builder = Volatile.Read(ref _builder);

            if (builder != null)
            {
                builder.Complete();
                await builder.Completion.ConfigureAwait(false);
            }
        }
Exemplo n.º 5
0
 protected override Task configureUpdateBatch(ProjectionUpdateBatch batch, TenantSliceRange <TDoc, TId> sliceGroup, CancellationToken token)
 {
     return(_runtime.Configure(batch.Queue, sliceGroup.Groups, _token));
 }
Exemplo n.º 6
0
 public override Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                           EventRangeGroup eventRangeGroup)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 7
0
 public override Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                           EventRangeGroup eventRangeGroup)
 {
     throw new System.NotImplementedException();
 }