public void ConfigureServices(IServiceCollection services) { PrometheusMetrics.TryConfigure(Environment.ApplicationName); EventMapping.Map(); var esConnection = ConfigureEsConnection( Configuration["EventStore:ConnectionString"], Environment.ApplicationName); var documentStore = ConfigureRavenDb( Configuration["RavenDb:Server"], Configuration["RavenDb:Database"] ); var ravenDbStore = new RavenDBProvider(documentStore); services.AddSingleton(c => (Func <IAsyncDocumentSession>)GetSession); services.AddSingleton <IHostedService>( new EventStoreService( esConnection, Props.FromProducer(() => new SubscriptionActor( esConnection, new RavenDbCheckpointStore(GetSession, "readmodels"), "ravenDbSubscription", (Props.FromProducer( () => new CustomerVehiclesProjection(ravenDbStore)), "customerVehicles"), (Props.FromProducer( () => new VehicleItemProjection(ravenDbStore)), "vehicleItems") ) ) ) ); IAsyncDocumentSession GetSession() => documentStore.OpenAsyncSession(); }