Exemple #1
0
 public static IStatefulProjection Wrap(
     ProjectionGroupStateObserver observer,
     string name,
     IStatefulProjection projection) =>
 new StatefulProjectionBuilder(projection)
 .Use(projectMidfunc: downstream => async(message, ct) =>
 {
     if (observer[name].Checkpoint >= message.Checkpoint)
     {
         return;
     }
     await downstream(message, ct).ConfigureAwait(false);
     observer.MoveTo(name, message.Checkpoint);
 })
 .UseSuspendOnException(ex => observer.Suspend(name, ex))
 .Build();
Exemple #2
0
        public static async Task LoadCheckpoints(
            Func <IAsyncDocumentSession> sessionFactory,
            ProjectionGroupStateObserver observer,
            IEnumerable <string> keys)
        {
            using (var session = sessionFactory())
            {
                var docs = await session.LoadAsync <ProjectionPosition>(
                    keys.Select(ProjectionPosition.GetIdFromName)).ConfigureAwait(false);

                var pairs = keys.Zip(docs, (k, d) =>
                                     new KeyValuePair <string, AllStreamPosition>(k, AllStreamPosition.FromNullableInt64(d?.Position)));
                foreach (var pair in pairs)
                {
                    observer.MoveTo(pair.Key, pair.Value);
                }
            }
        }
Exemple #3
0
 private IStatefulProjection WrapLocalProjection(string name, IStatefulProjection projection) =>
 new StatefulProjectionBuilder(projection)
 .UseCheckpointStore(CheckpointsGroup.GetCheckpointStore(name), cp => Observer.MoveTo(name, cp))
 .UseCommitEvery()
 .UseSuspendOnException(ex => Observer.Suspend(name, ex))
 .Build();