public static IHealthChecksBuilder AddPingHealthCheck(this IHealthChecksBuilder builder, Action <PingHealthCheckOptions> setup, string name = default, HealthStatus?failureStatus = default, IEnumerable <string> tags = default, TimeSpan?timeout = default) { var options = new PingHealthCheckOptions(); setup?.Invoke(options); return(builder.Add(new HealthCheckRegistration( name ?? PING_NAME, sp => new PingHealthCheck(options), failureStatus, tags))); }
/// <summary> /// Adds Ping HealthCheck. /// </summary> /// <param name="builder">The healthcheck builder.</param> /// <param name="name">The name of the healthcheck.</param> /// <param name="options">The options for the healthcheck.</param> /// <param name="tags">The optional tags.</param> /// <returns></returns> public static IHealthChecksBuilder AddPingHealthCheck( this IHealthChecksBuilder builder, string name, PingHealthCheckOptions options, IEnumerable <string>?tags = default) { builder.Services.Configure <PingHealthCheckOptions>(op => { op.Host = options.Host; op.Timeout = options.Timeout; }); builder.AddCheck <PingHealthCheck>(name, failureStatus: null, tags: tags); return(builder); }
public PingHealthCheck(PingHealthCheckOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); }