Exemplo n.º 1
0
        private async Task processEventSlices(IShardAgent shardAgent, IAggregationRuntime <TDoc, TId> runtime,
                                              IDocumentStore store, CancellationToken token)
        {
            var beingFetched = new List <EventSlice <TDoc, TId> >();

            foreach (var slice in Slices)
            {
                if (token.IsCancellationRequested)
                {
                    _builder.Complete();
                    break;
                }

                if (runtime.IsNew(slice))
                {
                    _builder.Post(slice);
                }
                else
                {
                    beingFetched.Add(slice);
                }
            }

            if (token.IsCancellationRequested)
            {
                return;
            }

            var ids = beingFetched.Select(x => x.Id).ToArray();

            IReadOnlyList <TDoc> aggregates = null;

            await shardAgent.TryAction(async() =>
            {
                var options = new SessionOptions
                {
                    Tenant = Tenant, Tracking = DocumentTracking.None, AllowAnyTenant = true
                };

                using var session = (IMartenSession)store.OpenSession(options);
                aggregates        = await runtime.Storage
                                    .LoadManyAsync(ids, session, token).ConfigureAwait(false);
            }, token).ConfigureAwait(false);

            if (token.IsCancellationRequested || aggregates == null)
            {
                return;
            }

            var dict = aggregates.ToDictionary(x => runtime.Storage.Identity(x));

            foreach (var slice in Slices)
            {
                if (dict.TryGetValue(slice.Id, out var aggregate))
                {
                    slice.Aggregate = aggregate;
                }

                _builder.Post(slice);
            }
        }
Exemplo n.º 2
0
 public override Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                           EventRangeGroup eventRangeGroup)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 3
0
 public override Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                           EventRangeGroup eventRangeGroup)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 4
0
 public abstract Task ConfigureUpdateBatch(IShardAgent shardAgent, ProjectionUpdateBatch batch,
                                           EventRangeGroup eventRangeGroup);