public void Can_register_instance_health_checks() { // Arrange var builder = new HealthBuilder(); var check = new DatabaseHealthCheck(new Database()); // Act var health = builder.HealthChecks.AddCheck(check).Build(); // Assert health.Checks.Count().Should().Be(1); health.Checks.Single().Name.Should().Be("DatabaseCheck"); }
//To Update Category Item public async Task <DatabaseHealthCheck> UpdateHealthCheckCategory(DatabaseHealthCheck dbHealthCheck) { try { using (SystemHealthChecksDbContext shc = new SystemHealthChecksDbContext()) { shc.Update(dbHealthCheck); return(await Task.FromResult((shc.SaveChanges() > 0 ? dbHealthCheck : new DatabaseHealthCheck()))); } } catch (Exception ex) { return(null); } }
//To Add New Category public async Task <bool> DBHealthCheck(DatabaseHealthCheck dbHealthCheck) { try { using (SystemHealthChecksDbContext shc = new SystemHealthChecksDbContext()) { shc.DatabaseHealthCheck.Add(dbHealthCheck); return(await Task.FromResult((shc.SaveChanges() > 0 ? true : false))); } } catch (Exception ex) { return(false); } }
//To Delete Category Item public async Task <bool> DeleteDatabaseHealthCheck(int id) { try { using (SystemHealthChecksDbContext shc = new SystemHealthChecksDbContext()) { DatabaseHealthCheck dbHealthCheck = shc.DatabaseHealthCheck.Find(id); shc.DatabaseHealthCheck.Remove(dbHealthCheck); return(await Task.FromResult((shc.SaveChanges() > 0 ? true : false))); } } catch (Exception ex) { return(false); } }
public void Start(DocumentStoreConfiguration config) { _config = config; BuildContainer(config); if (_config.EnableSingleAggregateRepositoryCache) { _logger.InfoFormat("Single Aggregate Repository Cache - ENABLED"); JarvisFrameworkGlobalConfiguration.EnableSingleAggregateRepositoryCache(); } else { _logger.InfoFormat("Single Aggregate Repository Cache - DISABLED"); JarvisFrameworkGlobalConfiguration.DisableSingleAggregateRepositoryCache(); } if (_config.DisableRepositoryLockOnAggregateId) { _logger.InfoFormat("Repository lock on Aggregate Id - DISABLED"); NeventStoreExGlobalConfiguration.DisableRepositoryLockOnAggregateId(); } else { _logger.InfoFormat("Repository lock on Aggregate Id - ENABLED"); NeventStoreExGlobalConfiguration.EnableRepositoryLockOnAggregateId(); } Manager = BuildTenants(_container, config); //Setup database check. foreach (var tenant in _config.TenantSettings) { foreach (var connection in _databaseNames) { DatabaseHealthCheck check = new DatabaseHealthCheck( String.Format("Tenant: {0} [Db:{1}]", tenant.TenantId, connection), tenant.GetConnectionString(connection)); } } while (StartupCheck() == false) { _logger.InfoFormat("Some precondition to start the service are not met. Will retry in 3 seconds!"); Thread.Sleep(3000); } if (RebuildSettings.ShouldRebuild && Environment.UserInteractive) { Console.WriteLine("---> Set Log Level to INFO to speedup rebuild (y/N)?"); var res = Console.ReadLine().Trim().ToLowerInvariant(); if (res == "y") { SetLogLevelTo("INFO"); } } _logger.DebugFormat( "Roles:\n api: {0}\n worker : {1}\n projections: {2}", config.IsApiServer, config.IsWorker, config.IsReadmodelBuilder ); InitializeEverything(config); //Check if container misconfigured _container.CheckConfiguration(); }