Beispiel #1
0
        public static IServiceCollection AddEventStore(
            this IServiceCollection services,
            Action <EventStoreOptionsBuilder> configure)
        {
            services.TryAddSingleton <CosmosEventSerializer>();
            services.TryAddSingleton <IEventStoreClient, EventStoreClient>();
            services.TryAddSingleton <IEventStoreManagementClient, EventStoreManagementClient>();

            var configureOptions = new EventStoreOptionsBuilder(services);

            configure?.Invoke(configureOptions);

            services.TryAddSingleton <IDateTimeProvider, UtcDateTimeProvider>();
            services.TryAddSingleton <IEventIdProvider, GuidEventIdProvider>();

            services.TryAddSingleton <IStreamWriteValidator, StreamWriteValidator>();
            services.TryAddSingleton <IStreamReadValidator, StreamReadValidator>();
            services.TryAddSingleton <IEventBatchProducer, EventBatchProducer>();

            services.TryAddSingleton <IStreamInfoReader, StreamInfoReader>();
            services.TryAddSingleton <IStreamReader, StreamReader>();
            services.TryAddSingleton <IStreamWriter, StreamWriter>();

            services.TryAddSingleton <ISubscriptionTelemetry, SubscriptionTelemetry>();

            return(services);
        }
Beispiel #2
0
        private static EventStoreOptions EventStoreOptionsFactory(
            [NotNull] IServiceProvider applicationServiceProvider,
            [CanBeNull] Action <IServiceProvider, EventStoreOptionsBuilder> optionsAction)
        {
            var builder = new EventStoreOptionsBuilder(new EventStoreOptions());

            optionsAction?.Invoke(applicationServiceProvider, builder);
            return(builder.Options);
        }
        public static IServiceCollection AddEventStore(this IServiceCollection services, Action <IServiceProvider, EventStoreOptionsBuilder> optionsAction = null)
        {
            services.AddSingleton <IEventStore, EventStore>();
            services.AddSingleton <ISnapshotStore, SnapshotStore>();

            services.AddSingleton <IConfigureOptions <Abstractions.EventStoreOptions>, ConfigureEventStoreOptions>();

            services.Add(new ServiceDescriptor(typeof(Infrastructure.EventStoreOptions),
                                               serviceProvider =>
            {
                var builder = new EventStoreOptionsBuilder();
                optionsAction?.Invoke(serviceProvider, builder);
                return(builder.Options);
            }, ServiceLifetime.Singleton));

            return(services);
        }
Beispiel #4
0
        public static EventStoreOptionsBuilder UseCQRS(
            this EventStoreOptionsBuilder builder,
            Action <IEventStoreCqrsBuilder> configure)
        {
            var cqrsBuilder = new EventStoreCqrsBuilder(builder);

            configure?.Invoke(cqrsBuilder);

            builder.Services.AddSingleton(typeof(IStateProjector <>), typeof(StateProjector <>));
            builder.Services.AddSingleton(typeof(IStateWriter <>), typeof(StateWriter <>));
            builder.Services.AddTransient(typeof(ICommandProcessor <>), typeof(CommandProcessor <>));
            builder.Services.AddSingleton <ICommandProcessorFactory, CommandProcessorFactory>();
            builder.Services.AddSingleton <IProjectionOptionsFactory, ProjectionOptionsFactory>();
            builder.Services.AddSingleton <IProjectionFactory, ProjectionFactory>();

            builder.Services.AddSingleton(typeof(ProjectionMetadata <>));

            builder.Services.TryAddSingleton <IProjectionDiagnostics, ProjectionDiagnostics>();
            builder.Services.TryAddSingleton <IProjectionProcessOperation, ProjectionProcessOperation>();

            return(builder);
        }
Beispiel #5
0
 public EventStoreCqrsBuilder(EventStoreOptionsBuilder builder)
 {
     this.builder = builder;
 }