コード例 #1
0
 public TcpHealthProbeService(
     HealthCheckService healthCheckService,
     ILogger <TcpHealthProbeService> logger,
     TcpHealthProbeOptions options)
 {
     _healthCheckService = healthCheckService ?? throw new ArgumentNullException(nameof(healthCheckService));
     _logger             = logger;
     _options            = options;
     _listener           = new TcpListener(options.IpAddress, options.Port);
 }
コード例 #2
0
        public static IServiceCollection AddTcpHealthProbe(
            this IServiceCollection services,
            Action <TcpHealthProbeOptions> setupOptions)
        {
            var options = new TcpHealthProbeOptions();

            setupOptions(options);

            services.AddSingleton(options);

            services.AddHealthChecks();

            services.AddHostedService <TcpHealthProbeService>();

            return(services);
        }