Пример #1
0
        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)));
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
 public PingHealthCheck(PingHealthCheckOptions options)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
 }