protected virtual void SetSnapshotStrategy(ISnapshotStrategy snapshotStrategy) { if (snapshotStrategy != null) { SnapshotStrategy = snapshotStrategy; } }
public EventsourcedScheduler(Config config = null) { this._settings = config == null?EventsourcedSchedulerSettings.Get(Context.System) : EventsourcedSchedulerSettings.From(config); this._snapshotStrategy = FactoryUtils.Create <ISnapshotStrategy>(this._settings.SnapshotStrategyType, this.Self.AsFactoryParameter(), config.AsFactoryParameter(), Context.System.AsFactoryParameter(), this._settings.AsFactoryParameter()); this._acknowledgementStrategy = FactoryUtils.Create <IAcknowledgementStrategy>(this._settings.AcknowledgementStrategyType, this.Self.AsFactoryParameter(), config.AsFactoryParameter(), Context.System.AsFactoryParameter(), this._settings.AsFactoryParameter()); }
public Repository(IEventStore storage, ISnapshotStore snapshotStore, IEventPublisher publisher, ISnapshotStrategy snapshotStrategy) { _storage = storage; _snapshotStore = snapshotStore; _publisher = publisher; _snapshotStrategy = snapshotStrategy; }
public SnapshotRepository(ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, IDomainRepository domainRepository, IDomainEventStore domainEventStore) { if (snapshotStore == null) { throw new ArgumentNullException("snapshotStore"); } if (snapshotStrategy == null) { throw new ArgumentNullException("snapshotStrategy"); } if (domainRepository == null) { throw new ArgumentNullException("domainRepository"); } if (domainEventStore == null) { throw new ArgumentNullException("domainEventStore"); } _snapshotStore = snapshotStore; _snapshotStrategy = snapshotStrategy; _domainRepository = domainRepository; _domainEventStore = domainEventStore; }
protected override void Load(ContainerBuilder builder) { // The generic ILogger<TCategoryName> service was added to the ServiceCollection by ASP.NET Core. // It was then registered with Autofac using the Populate method in ConfigureServices. builder.RegisterType <SerilogLogger>().As <ILog>(); builder.RegisterType <ExceptionHandlingMiddleware>(); builder.RegisterType <MongoDatabaseFactory>().As <IMongoDatabaseFactory>(); builder.RegisterType <AppointmentService>().As <IAppointmentService>(); builder.RegisterType <InMemoryEventBusSubscriptionsManager>().As <IEventBusSubscriptionsManager>(); builder.RegisterType <IntegrationTestEventHandler>().As <IIntegrationEventHandler>(); // builder.RegisterType<SagaUpdater<AppointmentAggregate, AppointmentId, AppointmentBookedEvent, AppointmentSaga>>().As<ISagaUpdater<AppointmentAggregate, AppointmentId, AppointmentBookedEvent, AppointmentSaga>>(); builder.RegisterType <OrdersApplicationService>().As <IOrdersApplicationService>(); builder.RegisterType <PaymentsApplicationService>().As <IPaymentsApplicationService>(); builder.RegisterType <PaymentProviderFactory>().As <IPaymentProviderFactory>(); builder.RegisterType <Payments.Domain.Payments.Providers.ConfigurationProvider>().As <Payments.Domain.Payments.Providers.IConfigurationProvider>(); builder.RegisterType <TestProvider1PaymentProvider>().As <IPaymentProvider>(); builder.RegisterType <ReadModelFactory <AppointmentReadModel> >().As <IReadModelFactory <AppointmentReadModel> >(); builder.RegisterType <ReadModelFactory <AppointmentInsertReadModel> >().As <IReadModelFactory <AppointmentInsertReadModel> >(); builder.RegisterType <AggregateReadStoreManager <AppointmentAggregate, AppointmentId, MongoDbReadModelStore <AppointmentReadModel>, AppointmentReadModel> >(); ISnapshotStrategy newStrategy = SnapshotEveryFewVersionsStrategy.With(10); builder.RegisterInstance(newStrategy); // builder.RegisterType<EventFlowOptionsSnapshotExtensions> builder.Populate(new ServiceCollection()); KafkaServicesRegistration.Register(builder); }
protected SnapshotAggregateRoot( TIdentity id, ISnapshotStrategy snapshotStrategy) : base(id) { SnapshotStrategy = snapshotStrategy; }
/// <summary> /// Initialize a new instance of SnapshotRepository /// </summary> /// <param name="snapshotStore">ISnapshotStore snapshots should be saved to and fetched from</param> /// <param name="snapshotStrategy">ISnapshotStrategy on when to take and if to restore from snapshot</param> /// <param name="repository">Reposiory that gets aggregate from event store</param> /// <param name="eventStore">Event store where events after snapshot can be fetched from</param> public SnapshotRepository(ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, IRepository repository, IEventStore eventStore) { _snapshotStore = snapshotStore ?? throw new ArgumentNullException(nameof(snapshotStore)); _snapshotStrategy = snapshotStrategy ?? throw new ArgumentNullException(nameof(snapshotStrategy)); _repository = repository ?? throw new ArgumentNullException(nameof(repository)); _eventStore = eventStore ?? throw new ArgumentNullException(nameof(eventStore)); }
public ProjectionRepository(CronusContext context, IProjectionStore projectionStore, ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, InMemoryProjectionVersionStore inMemoryVersionStore, IHandlerFactory handlerFactory, ProjectionHasher projectionHasher) { if (context is null) { throw new ArgumentException(nameof(context)); } if (projectionStore is null) { throw new ArgumentException(nameof(projectionStore)); } if (snapshotStore is null) { throw new ArgumentException(nameof(snapshotStore)); } if (snapshotStrategy is null) { throw new ArgumentException(nameof(snapshotStrategy)); } if (inMemoryVersionStore is null) { throw new ArgumentException(nameof(inMemoryVersionStore)); } this.context = context; this.projectionStore = projectionStore; this.snapshotStore = snapshotStore; this.snapshotStrategy = snapshotStrategy; this.inMemoryVersionStore = inMemoryVersionStore; this.handlerFactory = handlerFactory; this.projectionHasher = projectionHasher; }
public AggregateSnapshotRespositoryDecorator(IAggregateRepository decorated, IAggregateFactory aggregateFactory, IEventStore eventStore, ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy) { _decoratedRepository = decorated ?? throw new ArgumentNullException(nameof(decorated)); _aggregateFactory = aggregateFactory ?? throw new ArgumentNullException(nameof(aggregateFactory)); _eventStore = eventStore ?? throw new ArgumentNullException(nameof(eventStore)); _snapshotStore = snapshotStore ?? throw new ArgumentNullException(nameof(snapshotStore)); _snapshotStrategy = snapshotStrategy ?? throw new ArgumentNullException(nameof(snapshotStrategy)); }
public SnapshotRepository(ISnapshotStore snapshotStore, ISnapshotStrategy <TAuthenticationToken> snapshotStrategy, IRepository <TAuthenticationToken> repository, IEventStore <TAuthenticationToken> eventStore, IAggregateFactory aggregateFactory) { SnapshotStore = snapshotStore; SnapshotStrategy = snapshotStrategy; Repository = repository; EventStore = eventStore; AggregateFactory = aggregateFactory; }
public EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry> WithReadOneStreamFromStartCache( string streamId, IEventTypeProvider <TAggregate> eventTypeProvider, Action <MultipleStreamsCatchupCacheConfiguration <TAggregate> > getMultipleStreamsCatchupCacheConfiguration = null, ISnapshotStore <TAggregate> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null) { return(WithReadManyStreamsFromStartCache(new[] { streamId }, eventTypeProvider, getMultipleStreamsCatchupCacheConfiguration, snapshotStore, snapshotStrategy)); }
private Persistence(IProvider provider, string actorId, Action <Event> applyEvent = null, Action <Snapshot> applySnapshot = null, ISnapshotStrategy snapshotStrategy = null, Func <object> getState = null) { _actorId = actorId; _provider = provider; _applyEvent = applyEvent; _applySnapshot = applySnapshot; _getState = getState; _snapshotStrategy = snapshotStrategy ?? new NoSnapshots(); }
private Persistence(IEventStore eventStore, ISnapshotStore snapshotStore, string actorId, Action <Event> applyEvent = null, Action <Snapshot> applySnapshot = null, ISnapshotStrategy snapshotStrategy = null, Func <object> getState = null) { _eventStore = eventStore; _snapshotStore = snapshotStore; _actorId = actorId; _applyEvent = applyEvent; _applySnapshot = applySnapshot; _getState = getState; _snapshotStrategy = snapshotStrategy ?? new NoSnapshots(); }
public SnapshotRepository( IEventStorage eventStorage, ISnapshotStorage snapshotStorage, ISnapshotStrategy snapshotStrategy, IDomainEventMediator domainEventMediator) { _snapshotStorage = snapshotStorage ?? throw new ArgumentNullException(nameof(snapshotStorage)); _snapshotStrategy = snapshotStrategy ?? throw new ArgumentNullException(nameof(snapshotStrategy)); _eventStorage = eventStorage ?? throw new ArgumentNullException(nameof(eventStorage)); _domainEventMediator = domainEventMediator ?? throw new ArgumentNullException(nameof(domainEventMediator)); }
public static ISession Create( ITransaction transaction, IEventStore eventStore, ISnapshotStore snapshotStore, ILoggerFactory loggerFactory = null, IEventPublisher eventPublisher = null, IEventRouter eventRouter = null, IEventUpdateManager eventUpdateManager = null, IEnumerable <IMetadataProvider> metadataProviders = null, ISnapshotStrategy snapshotStrategy = null, IEventsMetadataService eventsMetadataService = null) { // TODO: refactor ctor's Session sucks :( if (eventStore == null) { throw new ArgumentNullException(nameof(eventStore)); } if (snapshotStore == null) { throw new ArgumentNullException(nameof(snapshotStore)); } if (loggerFactory == null) { loggerFactory = new NoopLoggerFactory(); } if (eventRouter == null) { eventRouter = StubEventRouter.Ok(); } if (eventPublisher == null) { eventPublisher = new EventPublisher(eventRouter); } var session = new Session( loggerFactory: loggerFactory, transaction: transaction, eventStore: eventStore, snapshotStore: snapshotStore, eventPublisher: eventPublisher, eventUpdateManager: eventUpdateManager, metadataProviders: metadataProviders, snapshotStrategy: snapshotStrategy, eventsMetadataService: eventsMetadataService); return(session); }
public Session( ILoggerFactory loggerFactory, ITransaction transaction, IEventStore eventStore, ISnapshotStore snapshotStore, IEventPublisher eventPublisher, IEventUpdateManager eventUpdateManager = null, IEnumerable <IMetadataProvider> metadataProviders = null, ISnapshotStrategy snapshotStrategy = null, IEventsMetadataService eventsMetadataService = null) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (metadataProviders == null) { metadataProviders = Enumerable.Empty <IMetadataProvider>(); } metadataProviders = metadataProviders.Concat(new IMetadataProvider[] { new AggregateTypeMetadataProvider(), new EventTypeMetadataProvider(), new CorrelationIdMetadataProvider() }); if (snapshotStrategy == null) { snapshotStrategy = new IntervalSnapshotStrategy(); } if (eventsMetadataService == null) { eventsMetadataService = new EventsMetadataService(); } _logger = loggerFactory.Create(nameof(Session)); _transaction = transaction ?? throw new ArgumentNullException(nameof(transaction)); _eventStore = eventStore ?? throw new ArgumentNullException(nameof(eventStore)); _snapshotStore = snapshotStore ?? throw new ArgumentNullException(nameof(snapshotStore)); _eventPublisher = eventPublisher ?? throw new ArgumentNullException(nameof(eventPublisher)); _snapshotStrategy = snapshotStrategy; _eventUpdateManager = eventUpdateManager; _metadataProviders = metadataProviders; _eventsMetadataService = eventsMetadataService; }
public static Persistence WithEventSourcingAndSnapshotting( IEventStore eventStore, ISnapshotStore snapshotStore, string actorId, Action <Event> applyEvent, Action <Snapshot> applySnapshot, ISnapshotStrategy snapshotStrategy, Func <object> getState ) { if (eventStore is null) { throw new ArgumentNullException(nameof(eventStore)); } if (snapshotStore is null) { throw new ArgumentNullException(nameof(snapshotStore)); } if (applyEvent is null) { throw new ArgumentNullException(nameof(applyEvent)); } if (applySnapshot is null) { throw new ArgumentNullException(nameof(applySnapshot)); } if (snapshotStrategy is null) { throw new ArgumentNullException(nameof(snapshotStrategy)); } if (getState is null) { throw new ArgumentNullException(nameof(getState)); } return(new Persistence(eventStore, snapshotStore, actorId, applyEvent, applySnapshot, snapshotStrategy, getState )); }
public EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry> WithReadAllFromStartCache( IEventTypeProvider <TAggregate> eventTypeProvider, Action <AllStreamsCatchupCacheConfiguration <TAggregate> > getCatchupEventStoreCacheConfigurationBuilder = null, ISnapshotStore <TAggregate> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null) { if (null != EventStoreCache) { throw new InvalidOperationException($"A cache has already been set => {EventStoreCache.GetType()}"); } var catchupEventStoreCacheConfiguration = new AllStreamsCatchupCacheConfiguration <TAggregate>(Position.Start); getCatchupEventStoreCacheConfigurationBuilder?.Invoke(catchupEventStoreCacheConfiguration); EventStoreCache = new AllStreamsCatchupCache <TAggregate>(ConnectionMonitor, catchupEventStoreCacheConfiguration, eventTypeProvider, LoggerFactory, snapshotStore, snapshotStrategy); return(this); }
public AggregateRootRepository( IEventStore eventStore, ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, ISnapshotRestoreUtility snapshotRestoreUtility, IEventPublisher eventPublisher) { _snapshotRestoreUtility = snapshotRestoreUtility; _eventPublisher = eventPublisher; _eventStore = eventStore ?? throw new ArgumentNullException(nameof(eventStore)); _snapshotStore = snapshotStore; _snapshotStrategy = snapshotStrategy ?? throw new ArgumentNullException(nameof(snapshotStrategy)); // Todo: Handle config flavors for snapshot store (cached vs non cached) if (SnapshotStore == null) { throw new ArgumentException(nameof(ISnapshotStore)); } }
public EventStoreStatefulActorBuilder <TActor, TAggregate, TRegistry> WithReadManyStreamsFromStartCache( string[] streamIds, IEventTypeProvider <TAggregate> eventTypeProvider, Action <MultipleStreamsCatchupCacheConfiguration <TAggregate> > getMultipleStreamsCatchupCacheConfiguration = null, ISnapshotStore <TAggregate> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null) { if (null != EventStoreCache) { throw new InvalidOperationException($"A cache has already been set => {EventStoreCache.GetType()}"); } var multipleStreamsCatchupCacheConfiguration = new MultipleStreamsCatchupCacheConfiguration <TAggregate>(streamIds); getMultipleStreamsCatchupCacheConfiguration?.Invoke(multipleStreamsCatchupCacheConfiguration); EventStoreCache = new MultipleStreamsCatchupCache <TAggregate>(ConnectionMonitor, multipleStreamsCatchupCacheConfiguration, eventTypeProvider, LoggerFactory, snapshotStore, snapshotStrategy); return(this); }
public static ISession Create( ITransaction transaction, ICompositeStores stores, ILoggerFactory loggerFactory = null, IEventPublisher eventPublisher = null, IEventRouter eventRouter = null, IEventUpdateManager eventUpdateManager = null, IEnumerable <IMetadataProvider> metadataProviders = null, ISnapshotStrategy snapshotStrategy = null, IEventsMetadataService eventsMetadataService = null) { return(Create(transaction, stores.EventStore, stores.SnapshotStore, loggerFactory, eventPublisher, eventRouter, eventUpdateManager, metadataProviders, snapshotStrategy, eventsMetadataService)); }
public SnapshotRepository(ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, IRepository repository, IEventStore eventStore) { if (snapshotStore == null) { throw new ArgumentNullException("snapshotStore"); } if (snapshotStrategy == null) { throw new ArgumentNullException("snapshotStrategy"); } if (repository == null) { throw new ArgumentNullException("repository"); } if (eventStore == null) { throw new ArgumentNullException("eventStore"); } _snapshotStore = snapshotStore; _snapshotStrategy = snapshotStrategy; _repository = repository; _eventStore = eventStore; }
public ProjectionRepository(IProjectionStore projectionStore, ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, InMemoryProjectionVersionStore inMemoryVersionStore) { if (ReferenceEquals(null, projectionStore) == true) { throw new ArgumentException(nameof(projectionStore)); } if (ReferenceEquals(null, snapshotStore) == true) { throw new ArgumentException(nameof(snapshotStore)); } if (ReferenceEquals(null, snapshotStrategy) == true) { throw new ArgumentException(nameof(snapshotStrategy)); } if (ReferenceEquals(null, inMemoryVersionStore) == true) { throw new ArgumentException(nameof(inMemoryVersionStore)); } this.projectionStore = projectionStore; this.snapshotStore = snapshotStore; this.snapshotStrategy = snapshotStrategy; this.inMemoryVersionStore = inMemoryVersionStore; }
public TradeSink(IEventStoreActorConfigurationFactory eventStoreCacheFactory, IConnectionStatusMonitor <IEventStoreConnection> connectionStatusMonitor, ISnapshotStore <Trade> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null, ILoggerFactory loggerFactory = null) : base(eventStoreCacheFactory, connectionStatusMonitor, snapshotStore, snapshotStrategy, loggerFactory) { }
public static Persistence WithEventSourcingAndSnapshotting(IProvider provider, string actorId, Action <Event> applyEvent, Action <Snapshot> applySnapshot, ISnapshotStrategy snapshotStrategy, Func <object> getState) { if (applyEvent == null) { throw new ArgumentNullException(nameof(applyEvent)); } if (applySnapshot == null) { throw new ArgumentNullException(nameof(applySnapshot)); } if (snapshotStrategy == null) { throw new ArgumentNullException(nameof(snapshotStrategy)); } if (getState == null) { throw new ArgumentNullException(nameof(getState)); } return(new Persistence(provider, actorId, applyEvent, applySnapshot, snapshotStrategy, getState)); }
public ParcelFactory(ISnapshotStrategy snapshotStrategy) { _snapshotStrategy = snapshotStrategy; }
public TestCatchupWithMailboxActor(IEventStoreActorConfigurationFactory eventStoreCacheFactory, IConnectionStatusMonitor <IEventStoreConnection> connectionStatusMonitor, ISnapshotStore <SomeDataAggregate> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null, ILoggerFactory loggerFactory = null) : base(eventStoreCacheFactory, connectionStatusMonitor, snapshotStore, snapshotStrategy, loggerFactory) { }
public TestStatefulActorOneHealthChecksMvc(IEventStoreActorConfigurationFactory eventStoreCacheFactory, IConnectionStatusMonitor <IEventStoreConnection> connectionStatusMonitor, ISnapshotStore <SomeDataAggregate> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null, ILoggerFactory loggerFactory = null) : base(eventStoreCacheFactory, connectionStatusMonitor, snapshotStore, snapshotStrategy, loggerFactory) { }
protected SnapshotAggregateRootBase(TIdentity id, ISnapshotStrategy snapshotStrategy) : base(id, snapshotStrategy) { }
public EventCountStatefulActor(IEventStoreActorConfigurationFactory eventStoreCacheFactory, IConnectionStatusMonitor <IEventStoreConnection> connectionStatusMonitor, ISnapshotStore <EventCountAggregate> snapshotStore = null, ISnapshotStrategy snapshotStrategy = null, ILoggerFactory loggerFactory = null) : base(eventStoreCacheFactory, connectionStatusMonitor, snapshotStore, snapshotStrategy, loggerFactory) { }