Exemplo n.º 1
0
        public static ElectHealthCheckOptions GetOptions(IConfiguration configuration, string sectionName = "ElectHealthCheck")
        {
            var electHealthCheckOptions = new ElectHealthCheckOptions();

            electHealthCheckOptions.IsEnable = configuration.GetValueByEnv <bool>($"{sectionName}:{nameof(electHealthCheckOptions.IsEnable)}");

            electHealthCheckOptions.Endpoint = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electHealthCheckOptions.Endpoint)}");

            electHealthCheckOptions.DbConnectionString = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electHealthCheckOptions.DbConnectionString)}");

            return(electHealthCheckOptions);
        }
Exemplo n.º 2
0
        public ConsulHostedService(IConsulClient consulClient,
                                   IOptions <ElectConsulOptions> consulConfig,
                                   IOptions <ElectHealthCheckOptions> healthCheckOptions,
                                   IServer server,
                                   ILoggerFactory loggerFactory)
        {
            _server = server;

            _consulConfig = consulConfig.Value;

            _healthCheckConfig = healthCheckOptions.Value;

            _logger = loggerFactory.CreateLogger <IHostedService>();

            _consulClient = consulClient;
        }
 public static IServiceCollection AddElectHealthCheck(this IServiceCollection services, [NotNull] ElectHealthCheckOptions configure)
 {
     return(services.AddElectHealthCheck(_ =>
     {
         _.IsEnable = configure.IsEnable;
         _.Endpoint = configure.Endpoint;
         _.DbConnectionString = configure.DbConnectionString;
         _.Builder = configure.Builder;
         _.Options = configure.Options;
     }));
 }