public IEnumerable <ConfigurationSetupResult> Setup(string applicationEnvironment) { yield return(new ConfigurationSetupResult("superglue.TimeoutManager.Configure", environment => { var timeOutManagerName = environment.Get <string>(RavenTimeoutManagerEnvironmentConstants.TimeoutManagerName); var connectionStringName = environment.Get <string>(RavenTimeoutManagerEnvironmentConstants.ConnectionStringName) ?? "RavenDb"; var databaseName = environment.Get <string>(RavenTimeoutManagerEnvironmentConstants.TimeoutDatabaseName); var documentStore = new DocumentStore { ConnectionStringName = connectionStringName }; if (!string.IsNullOrEmpty(databaseName)) { documentStore.DefaultDatabase = databaseName; } documentStore.Initialize(); new RavenTimeOutDataIndex().Execute(documentStore); TimeOutManager.Configure(() => new StoreTimeOutsInRavenDb(documentStore, timeOutManagerName, databaseName)); return Task.CompletedTask; }, "superglue.RavenDb.Configure")); }
public IEnumerable <ConfigurationSetupResult> Setup(string applicationEnvironment) { yield return(new ConfigurationSetupResult("superglue.EventStore.Setup", environment => { environment.AlterSettings <EventStoreSettings>(x => { x.ModifySettings(y => { y.KeepReconnecting(); y.KeepRetrying(); y.UseCustomLogger(new EventStoreLog(environment)); }); x.StoreCommands((env, command, id, causationId) => "commands"); }); environment.AlterSettings <IocConfiguration>(x => x.Register(typeof(IEventStoreConnection), (y, z) => connection, RegistrationLifecycle.Singletone) .Register(typeof(EventStoreConnectionString), (y, z) => connectionString, RegistrationLifecycle.Singletone) .Register(typeof(IHandleEventSerialization), typeof(DefaultEventSerializer)) .Register(typeof(IRepository), typeof(DefaultRepository)) .Register(typeof(ICheckConflicts), typeof(DefaultConflictChecker)) .Register(typeof(IManageTimeOuts), typeof(DefaultTimeOutManager)) .Scan(typeof(IManageChanges)) .ScanOpenType(typeof(ICheckConflict <,>))); TimeOutManager.Configure(() => new StoreTimeoutsInMemory()); return Task.CompletedTask; }, "superglue.LoggingSetup", environment => { connection.Close(); return Task.CompletedTask; }, configuration => { var connectionInformation = configuration .WithSettings <EventStoreSettings>() .CreateConnection(configuration.Settings.Resolve <IApplicationConfiguration>()); connection = connectionInformation.Item2; connectionString = connectionInformation.Item1; return connection.ConnectAsync(); })); }