Example #1
0
        private void RegisterDefaults(IServiceRegistration serviceRegistration)
        {
            serviceRegistration.Register <ILog, ConsoleLog>();
            serviceRegistration.Register <IAggregateStoreResilienceStrategy, NoAggregateStoreResilienceStrategy>();
            serviceRegistration.Register <IDispatchToReadStoresResilienceStrategy, NoDispatchToReadStoresResilienceStrategy>();
            serviceRegistration.Register <ISagaUpdateResilienceStrategy, NoSagaUpdateResilienceStrategy>();
            serviceRegistration.Register <IDispatchToSubscriberResilienceStrategy, NoDispatchToSubscriberResilienceStrategy>();
            serviceRegistration.Register <IDispatchToReadStores, DispatchToReadStores>();
            serviceRegistration.Register <IEventStore, EventStoreBase>();
            serviceRegistration.Register <IEventPersistence, InMemoryEventPersistence>(Lifetime.Singleton);
            serviceRegistration.Register <ICommandBus, CommandBus>();
            serviceRegistration.Register <IAggregateStore, AggregateStore>();
            serviceRegistration.Register <ISnapshotStore, SnapshotStore>();
            serviceRegistration.Register <ISnapshotSerilizer, SnapshotSerilizer>();
            serviceRegistration.Register <ISnapshotPersistence, NullSnapshotPersistence>();
            serviceRegistration.Register <ISnapshotUpgradeService, SnapshotUpgradeService>();
            serviceRegistration.Register <ISnapshotDefinitionService, SnapshotDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IReadModelPopulator, ReadModelPopulator>();
            serviceRegistration.Register <IEventJsonSerializer, EventJsonSerializer>();
            serviceRegistration.Register <IEventDefinitionService, EventDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IQueryProcessor, QueryProcessor>();
            serviceRegistration.Register <IJsonSerializer, JsonSerializer>(Lifetime.Singleton);
            serviceRegistration.Register <IJsonOptions, JsonOptions>();
            serviceRegistration.Register <IJobScheduler, InstantJobScheduler>();
            serviceRegistration.Register <IJobRunner, JobRunner>();
            serviceRegistration.Register <IJobDefinitionService, JobDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IOptimisticConcurrencyRetryStrategy, OptimisticConcurrencyRetryStrategy>();
            serviceRegistration.Register <IEventUpgradeManager, EventUpgradeManager>(Lifetime.Singleton);
            serviceRegistration.Register <IAggregateFactory, AggregateFactory>();
            serviceRegistration.Register <IReadModelDomainEventApplier, ReadModelDomainEventApplier>();
            serviceRegistration.Register <IDomainEventPublisher, DomainEventPublisher>();
            serviceRegistration.Register <ISerializedCommandPublisher, SerializedCommandPublisher>();
            serviceRegistration.Register <ICommandDefinitionService, CommandDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IDispatchToEventSubscribers, DispatchToEventSubscribers>();
            serviceRegistration.Register <IDomainEventFactory, DomainEventFactory>(Lifetime.Singleton);
            serviceRegistration.Register <ISagaDefinitionService, SagaDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <ISagaStore, SagaAggregateStore>();
            serviceRegistration.Register <ISagaErrorHandler, SagaErrorHandler>();
            serviceRegistration.Register <IDispatchToSagas, DispatchToSagas>();
#if NET452
            serviceRegistration.Register <IMemoryCache, MemoryCache>(Lifetime.Singleton);
#else
            serviceRegistration.Register <IMemoryCache, DictionaryMemoryCache>(Lifetime.Singleton);
#endif
            serviceRegistration.RegisterGeneric(typeof(ISagaUpdater <, , ,>), typeof(SagaUpdater <, , ,>));
            serviceRegistration.Register <IEventFlowConfiguration>(_ => _eventFlowConfiguration);
            serviceRegistration.Register <ICancellationConfiguration>(_ => _eventFlowConfiguration);
            serviceRegistration.RegisterGeneric(typeof(ITransientFaultHandler <>), typeof(TransientFaultHandler <>));
            serviceRegistration.RegisterGeneric(typeof(IReadModelFactory <>), typeof(ReadModelFactory <>), Lifetime.Singleton);
            serviceRegistration.Register <IBootstrap, DefinitionServicesInitilizer>();
            serviceRegistration.Register(_ => ModuleRegistration, Lifetime.Singleton);
            serviceRegistration.Register <ILoadedVersionedTypes>(r => new LoadedVersionedTypes(
                                                                     _jobTypes,
                                                                     _commandTypes,
                                                                     _aggregateEventTypes,
                                                                     _sagaTypes,
                                                                     _snapshotTypes),
                                                                 Lifetime.Singleton);
        }
Example #2
0
        private void RegisterDefaults(IServiceRegistration serviceRegistration)
        {
            // http://docs.autofac.org/en/latest/register/registration.html
            // Maybe swap around and do after and and .PreserveExistingDefaults()

            serviceRegistration.Register <ILog, ConsoleLog>();
            serviceRegistration.Register <IEventStore, EventStoreBase>();
            serviceRegistration.Register <IEventPersistence, InMemoryEventPersistence>(Lifetime.Singleton);
            serviceRegistration.Register <ICommandBus, CommandBus>();
            serviceRegistration.Register <IAggregateStore, AggregateStore>();
            serviceRegistration.Register <ISnapshotStore, SnapshotStore>();
            serviceRegistration.Register <ISnapshotSerilizer, SnapshotSerilizer>();
            serviceRegistration.Register <ISnapshotPersistence, NullSnapshotPersistence>();
            serviceRegistration.Register <ISnapshotUpgradeService, SnapshotUpgradeService>();
            serviceRegistration.Register <ISnapshotDefinitionService, SnapshotDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IReadModelPopulator, ReadModelPopulator>();
            serviceRegistration.Register <IEventJsonSerializer, EventJsonSerializer>();
            serviceRegistration.Register <IEventDefinitionService, EventDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IQueryProcessor, QueryProcessor>(Lifetime.Singleton);
            serviceRegistration.Register <IJsonSerializer, JsonSerializer>();
            serviceRegistration.Register <ITaskRunner, TaskRunner>();
            serviceRegistration.Register <IJobScheduler, InstantJobScheduler>();
            serviceRegistration.Register <IJobRunner, JobRunner>();
            serviceRegistration.Register <IJobDefinitionService, JobDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IOptimisticConcurrencyRetryStrategy, OptimisticConcurrencyRetryStrategy>();
            serviceRegistration.Register <IEventUpgradeManager, EventUpgradeManager>(Lifetime.Singleton);
            serviceRegistration.Register <IAggregateFactory, AggregateFactory>();
            serviceRegistration.Register <IReadModelDomainEventApplier, ReadModelDomainEventApplier>();
            serviceRegistration.Register <IDomainEventPublisher, DomainEventPublisher>();
            serviceRegistration.Register <ISerializedCommandPublisher, SerializedCommandPublisher>();
            serviceRegistration.Register <ICommandDefinitionService, CommandDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <IDispatchToEventSubscribers, DispatchToEventSubscribers>();
            serviceRegistration.Register <IDomainEventFactory, DomainEventFactory>(Lifetime.Singleton);
            serviceRegistration.Register <ISagaDefinitionService, SagaDefinitionService>(Lifetime.Singleton);
            serviceRegistration.Register <ISagaStore, SagaAggregateStore>();
            serviceRegistration.Register <ISagaErrorHandler, SagaErrorHandler>();
            serviceRegistration.Register <IDispatchToSagas, DispatchToSagas>();
            serviceRegistration.Register <IMemoryCache, MemoryCache>(Lifetime.Singleton);
            serviceRegistration.RegisterGeneric(typeof(ISagaUpdater <, , ,>), typeof(SagaUpdater <, , ,>));
            serviceRegistration.Register <IEventFlowConfiguration>(_ => _eventFlowConfiguration);
            serviceRegistration.RegisterGeneric(typeof(ITransientFaultHandler <>), typeof(TransientFaultHandler <>));
            serviceRegistration.RegisterGeneric(typeof(IReadModelFactory <>), typeof(ReadModelFactory <>), Lifetime.Singleton);
            serviceRegistration.Register <IBootstrap, DefinitionServicesInitilizer>();
            serviceRegistration.Register(_ => ModuleRegistration, Lifetime.Singleton);
            serviceRegistration.Register <ILoadedVersionedTypes>(r => new LoadedVersionedTypes(
                                                                     _jobTypes,
                                                                     _commandTypes,
                                                                     _aggregateEventTypes,
                                                                     _sagaTypes,
                                                                     _snapshotTypes),
                                                                 Lifetime.Singleton);
        }