public ConsumerCorrelationMap( List <KeyValuePair <TypeContract, CorrelationMap> > maps, List <KeyValuePair <TypeContract, Func <TSubscriberDataContract, JsonContent, TSubscriberDataContract> > > mappers, ProjectorsBySubscription <TUowProvider> projectorsByNotificationContract) { _subscriberDataContractMaps = maps ?? new List <KeyValuePair <TypeContract, CorrelationMap> >(); _subscriberDataMappers = mappers ?? new List <KeyValuePair <TypeContract, Func <TSubscriberDataContract, JsonContent, TSubscriberDataContract> > >(); ProjectorsBySubscription = projectorsByNotificationContract ?? new ProjectorsBySubscription <TUowProvider>(); }
public static EventStoreConfiguration <TEventStoreUowProvider> ConfigureSubscribers <TEventStoreUowProvider, TProjectionProvider>( this EventStoreConfiguration <TEventStoreUowProvider> configuration, ProjectorsBySubscription <TProjectionProvider> subscribers) where TEventStoreUowProvider : class, IUowProvider where TProjectionProvider : IUowProvider { configuration.ConfigureSubscriptions(subscribers.Select(x => x.Key)); new RequestsRegistration <ProjectorsBySubscription <TProjectionProvider> >(() => subscribers) .Register <ConfiguredSubscribers, Subscriber>( (input, provider) => ProjectorStore <TEventStoreUowProvider, TProjectionProvider> .Subscriber(provider), Return.List); return(configuration); }
internal static void Handle( SubscriberMessage message, ProjectorsBySubscription <TProjectorUowProvider> projectorsBySubscription, NotificationsByCorrelations notificationsByCorrelations, Func <DateTimeOffset> clock, TProjectorUowProvider integrationProvider) { var consumer = projectorsBySubscription[message.Subscription]; consumer ( message.Event, notificationsByCorrelations, clock, integrationProvider ); }
public static Func <TypeContract, IEnumerable <Action <INotification, TUowProvider> > > Given <TUowProvider>( this ProjectorsBySubscription <TUowProvider> subscriptions, params IDomainEvent[] given) where TUowProvider : IUowProvider { var list = given.AsEvents().ToList().AsReadOnly(); return(n => subscriptions .Where(p => p.Key.NotificationContract.Equals(n)) .Select(p => p.Value) .Select <Projector <TUowProvider>, Action <INotification, TUowProvider> >(projector => (notification, provider) => projector( new Event { Notification = notification, EventId = list.OrderByDescending(g => g.EventId.Value).First().EventId.With(x => x.Increment()) }, NotificationsByCorrelations(list), () => DateTimeOffset.Now, provider))); }
internal static void HandleAndCommit( SubscriberMessage message, ProjectorsBySubscription <TProjectorUowProvider> projectorsBySubscription, Handler <TProjectorUowProvider> handler, NotificationsByCorrelationsFunction <TEventStoreUowProvider> notificationsByCorrelationsFunction, CommitWork <TProjectorUowProvider> commitProjectionProvider, CommitWork <TEventStoreUowProvider> commitEventStoreProvider, Func <DateTimeOffset> clock) { commitProjectionProvider ( projectionProvider => commitEventStoreProvider ( eventStoreProvider => handler ( message, projectorsBySubscription, notificationsByCorrelationsFunction(eventStoreProvider), clock, projectionProvider ) ) ); }