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); }
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); }