Exemplo n.º 1
0
        public static IServiceCollection AddPersistenceConfiguration(this IServiceCollection services)
        {
            const string connectionString = "ConnectTo=tcp://admin:changeit@localhost:1113;DefaultUserCredentials=admin:changeit;";
            var          esConnection     = EventStoreConnection.Create(connectionString, ConnectionSettings.Create().KeepReconnecting(), "KajSpike");
            var          store            = new EsAggregateStore(esConnection);

            var calenderDetails   = new List <ReadModels.CalendarDetails>();
            var calenderOverviews = new List <ReadModels.CalendarOverview>();
            var bookingDetails    = new List <ReadModels.BookingDetails>();

            services.AddSingleton <IEnumerable <ReadModels.CalendarDetails> >(calenderDetails);
            services.AddSingleton <IEnumerable <ReadModels.CalendarOverview> >(calenderOverviews);
            services.AddSingleton <IEnumerable <ReadModels.BookingDetails> >(bookingDetails);

            var subscription = new EsSubscription(esConnection, calenderDetails, calenderOverviews, bookingDetails);

            services.AddSingleton(esConnection);
            services.AddSingleton <IAggregateStore>(store);
            services.AddSingleton <IHostedService>(new EventStoreService(esConnection, subscription));
            return(services);
        }
Exemplo n.º 2
0
 public EventStoreService(IEventStoreConnection esConnection, EsSubscription subscription)
 {
     _esConnection = esConnection;
     _subscription = subscription;
 }