protected override async Task OnLoadSnapshot( CatchupCacheSubscriptionHolder <TAggregate>[]?catchupCacheSubscriptionHolders, ISnapshotStrategy?snapshotStrategy, ISnapshotStore <TAggregate>?snapshotStore) { if (UseSnapshot) { #nullable disable var eventTypeFilter = GetEventsFilters(); foreach (var catchupCacheSubscriptionHolder in catchupCacheSubscriptionHolders) { var snapshot = await snapshotStore.GetByVersionOrLast(catchupCacheSubscriptionHolder.StreamId, eventTypeFilter); if (null == snapshot) { continue; } catchupCacheSubscriptionHolder.CurrentSnapshotEventVersion = snapshot.VersionFromSnapshot; catchupCacheSubscriptionHolder.LastProcessedEventSequenceNumber = snapshot.VersionFromSnapshot; catchupCacheSubscriptionHolder.LastProcessedEventUtcTimestamp = DateTime.UtcNow; Logger?.LogInformation($"{Id} => OnLoadSnapshot - EntityId: {snapshot.EntityId} StreamId: {snapshot.EntityId}"); CurrentCache.AddOrUpdate(snapshot); } #nullable disable }
protected override EventStoreCatchUpSubscription GetEventStoreCatchUpSubscription( CatchupCacheSubscriptionHolder <TAggregate> catchupCacheSubscriptionHolder, IEventStoreConnection connection, Func <EventStoreCatchUpSubscription, ResolvedEvent, Task> onEvent, Action <EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> onSubscriptionDropped) { void onCaughtUp(EventStoreCatchUpSubscription _) { catchupCacheSubscriptionHolder.OnCaughtUpSubject.OnNext(true); } var eventTypeFilter = GetEventsFilters(); var filter = Filter.EventType.Prefix(eventTypeFilter); Logger?.LogInformation($"{Id} => {nameof(AllStreamsCatchupCache<TAggregate>)} - {nameof(GetEventStoreCatchUpSubscription)} - FilteredSubscribeToAllFrom - Filters [{string.Join("|", eventTypeFilter)}]"); var subscription = connection.FilteredSubscribeToAllFrom( _catchupCacheConfiguration.Checkpoint, filter, _catchupCacheConfiguration.CatchUpSubscriptionFilteredSettings, eventAppeared: onEvent, liveProcessingStarted: onCaughtUp, subscriptionDropped: onSubscriptionDropped, userCredentials: _catchupCacheConfiguration.UserCredentials); return(subscription); }
protected override Task OnLoadSnapshot(CatchupCacheSubscriptionHolder <TAggregate>[]?catchupCacheSubscriptionHolders, ISnapshotStrategy?snapshotStrategy, ISnapshotStore <TAggregate>?snapshotStore) { return(Task.CompletedTask); }