Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HealthCheckRunner"/> class.
        /// </summary>
        /// <param name="healthChecks">
        /// The collection of <see cref="IHealthCheck"/> objects to be checked by this runner.
        /// </param>
        /// <param name="name">The name of the runner (optional).</param>
        /// <param name="description">The human-friendly description of the service.</param>
        /// <param name="serviceId">The unique identifier of the service, in the application scope.</param>
        /// <param name="version">The public version of the service.</param>
        /// <param name="releaseId">The "release version" or "release ID" of the service.</param>
        /// <param name="responseCustomizer">
        /// The <see cref="IHealthResponseCustomizer"/> that customizes each <see cref="HealthResponse"/>
        /// object returned by this runner.
        /// </param>
        /// <param name="contentType">
        /// The HTTP content type of responses created by this health check runner. Must not have a null or empty
        /// value.
        /// </param>
        /// <param name="passStatusCode">
        /// The HTTP status code of responses created by this health check runner that have a status of <see cref=
        /// "HealthStatus.Pass"/>. Must have a value in the 200-399 range.
        /// </param>
        /// <param name="warnStatusCode">
        /// The HTTP status code of responses created by this health check runner that have a status of <see cref=
        /// "HealthStatus.Warn"/>. Must have a value in the 200-399 range.
        /// </param>
        /// <param name="failStatusCode">
        /// The HTTP status code of responses created by this health check runner that have a status of <see cref=
        /// "HealthStatus.Fail"/>. Must have a value in the 400-599 range.
        /// </param>
        public HealthCheckRunner(IEnumerable <IHealthCheck> healthChecks = null, string name = null,
                                 string description = null, string serviceId = null, string version = null, string releaseId = null,
                                 IHealthResponseCustomizer responseCustomizer = null, string contentType = DefaultContentType,
                                 int passStatusCode = DefaultPassStatusCode, int warnStatusCode          = DefaultWarnStatusCode, int failStatusCode = DefaultFailStatusCode)
        {
            if (string.IsNullOrEmpty(contentType))
            {
                throw new ArgumentNullException(nameof(contentType));
            }
            if (passStatusCode < 200 || passStatusCode > 399)
            {
                throw new ArgumentOutOfRangeException(nameof(passStatusCode), "Must be in the range of 200-399.");
            }
            if (warnStatusCode < 200 || warnStatusCode > 399)
            {
                throw new ArgumentOutOfRangeException(nameof(warnStatusCode), "Must be in the range of 200-399.");
            }
            if (failStatusCode < 400 || failStatusCode > 599)
            {
                throw new ArgumentOutOfRangeException(nameof(failStatusCode), "Must be in the range of 400-599.");
            }

            HealthChecks       = (healthChecks ?? Enumerable.Empty <IHealthCheck>()) as IReadOnlyListOfIHealthCheck ?? healthChecks.ToList();
            Name               = name;
            Description        = description;
            ServiceId          = serviceId;
            Version            = version;
            ReleaseId          = releaseId;
            ResponseCustomizer = responseCustomizer;
            ContentType        = contentType;
            PassStatusCode     = passStatusCode;
            WarnStatusCode     = warnStatusCode;
            FailStatusCode     = failStatusCode;
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HealthCheckRunner"/> class.
 /// </summary>
 /// <param name="healthChecks">
 /// The collection of <see cref="IHealthCheck"/> objects to be checked by this runner.
 /// </param>
 /// <param name="name">The name of the runner (optional).</param>
 /// <param name="description">The human-friendly description of the service.</param>
 /// <param name="serviceId">The unique identifier of the service, in the application scope.</param>
 /// <param name="version">The public version of the service.</param>
 /// <param name="releaseId">The "release version" or "release ID" of the service.</param>
 /// <param name="responseCustomizer">
 /// The <see cref="IHealthResponseCustomizer"/> that customizes each <see cref="HealthResponse"/>
 /// object returned by this runner.
 /// </param>
 /// <param name="contentType">
 /// The HTTP content type of responses created by this health check runner. Must not have a null or empty
 /// value.
 /// </param>
 /// <param name="passStatusCode">
 /// The HTTP status code of responses created by this health check runner that have a status of <see cref=
 /// "HealthStatus.Pass"/>. Must have a value in the 200-399 range.
 /// </param>
 /// <param name="warnStatusCode">
 /// The HTTP status code of responses created by this health check runner that have a status of <see cref=
 /// "HealthStatus.Warn"/>. Must have a value in the 200-399 range.
 /// </param>
 /// <param name="failStatusCode">
 /// The HTTP status code of responses created by this health check runner that have a status of <see cref=
 /// "HealthStatus.Fail"/>. Must have a value in the 400-599 range.
 /// </param>
 public HealthCheckRunner(IEnumerable <IHealthCheck> healthChecks, string name, string description, string serviceId,
                          string version, string releaseId, IHealthResponseCustomizer responseCustomizer, string contentType,
                          int passStatusCode, int warnStatusCode, int failStatusCode)
     : this(healthChecks, name, description, serviceId, version, releaseId, responseCustomizer, contentType,
            passStatusCode, warnStatusCode, failStatusCode, DefaultUncaughtExceptionStatus)
 {
 }