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 ReqrepManager(string info, PType prefix) { lock ( _inst_tab_sync ) { _instance_table.Replace(info, this); } _info = info; _prefix = prefix; #if BRUNET_SIMULATOR Random r = Node.SimulatorRandom; #else Random r = new Random(); #endif //Don't use negative numbers: _req_state_table = new UidGenerator <RequestState>(r, true); //Don't use negative numbers: _reply_id_table = new UidGenerator <ReplyState>(r, true); /** * We keep a list of the most recent 1000 replies until they * get too old. If the reply gets older than reptimeout, we * remove it */ _reply_cache = new Cache(1000); _reply_cache.EvictionEvent += HandleReplyCacheEviction; _to_mgr = new TimeOutManager(); }
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(); })); }
void IDisposable.Dispose() { if (!_disposed) { if (_state == HttpServerState.Started) { Stop(); } if (_clientsChangedEvent != null) { ((IDisposable)_clientsChangedEvent).Dispose(); _clientsChangedEvent = null; } _disposed = true; } if (TimeOutManager != null) { TimeOutManager.Dispose(); TimeOutManager = null; } }
public ReqrepManager(string info, PType prefix) { lock( _inst_tab_sync ) { _instance_table.Replace(info, this); } _info = info; _prefix = prefix; #if BRUNET_SIMULATOR Random r = Node.SimulatorRandom; #else Random r = new Random(); #endif //Don't use negative numbers: _req_state_table = new UidGenerator<RequestState>(r, true); //Don't use negative numbers: _reply_id_table = new UidGenerator<ReplyState>(r, true); /** * We keep a list of the most recent 1000 replies until they * get too old. If the reply gets older than reptimeout, we * remove it */ _reply_cache = new Cache(1000); _reply_cache.EvictionEvent += HandleReplyCacheEviction; _to_mgr = new TimeOutManager(); }
/** * Protected constructor, we want to control ReqrepManager instances * running on a node. * @param info some context that we work for */ public ReqrepManager(object info) { ReqrepManager existing; lock( _inst_tab_sync ) { if(_instance_table.TryGetValue(info, out existing) ) { throw new Exception("Already an existing ReqrepManager for: " + info.ToString()); } else { _instance_table[info] = this; } } _info = info.ToString(); Random r = new Random(); //Don't use negative numbers: _req_state_table = new UidGenerator<RequestState>(r, true); //Don't use negative numbers: _reply_id_table = new UidGenerator<ReplyState>(r, true); /** * We keep a list of the most recent 1000 replies until they * get too old. If the reply gets older than reptimeout, we * remove it */ _reply_cache = new Cache(1000); _reply_cache.EvictionEvent += HandleReplyCacheEviction; _to_mgr = new TimeOutManager(); }