public static async Task Project <T>(this Projector <T> projector, string streamName, ISnapshotStore snapshotManager) where T : class, new() { var p = await projector.ProjectAsync(streamName); await snapshotManager.Apply <T>(typeof(T).Name, snap => p); }
public static GameModule Initialize( IAdvancedEventStore store, ISnapshotStore snapshotStore, Func <IEvent[], Task> pub) => new Configuration <GameModule>((c, p, q, s) => new GameModule(c, p, q, s)) .Commands( Commands.Validate <ICommand>(), Commands.GuaranteeCorrelation <ICommand>(), cmd => store.ExecuteAsync <GameState>(cmd, state => Game.Handle(cmd, state), async events => { await snapshotStore.Apply <GamesView>(events.Select(e => e.Event).Apply); await pub(events); }, snapshotStore, state => state.Version, (newVersion, state) => state.Pipe(x => x with {
public static Task Apply <T>(this ISnapshotStore snapshotStore, Func <T, T> f) where T : class, new() => snapshotStore.Apply <T>(typeof(T).Name, f);