Example #1
0
 public ConsulStatusReportBgTask(IConsulClient consulClient, ILogger <ConsulStatusReportBgTask> logger,
                                 IServer server, IConfiguration configuration, ConsulServiceConfiguration serviceConfiguration)
 {
     _consulClient       = consulClient;
     _logger             = logger;
     _server             = server;
     _configuration      = configuration;
     _serviceConfuration = serviceConfiguration;
 }
Example #2
0
        public static IServiceCollection UseTTLConsul(this IServiceCollection services, IConfiguration configuration)
        {
            var consulServiceConfig = new ConsulServiceConfiguration();

            configuration.GetSection(ConsulServiceConfiguration.Section).Bind(consulServiceConfig);
            services.AddSingleton(consulServiceConfig);

            string consulAddress = consulServiceConfig.ConsulUrl;

            services.AddSingleton <IConsulClient>(new ConsulClient(o =>
            {
                o.Address = new Uri(consulAddress);
            }));

            services.AddHostedService <ConsulStatusReportBgTask>();
            return(services);
        }