public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
 {
     return(await _service.CheckIsHealthy(MaxMessageAge)
         ? new HealthCheckResult(HealthStatus.Healthy)
         : new HealthCheckResult(context.Registration.FailureStatus,
                                 $"The outbound queue exceeded the configured limits " +
                                 $"(max message age: {MaxMessageAge.ToString()}, " +
                                 $"max queue length: {MaxQueueLength?.ToString() ?? "-"})."));
 }
Ejemplo n.º 2
0
        /// <inheritdoc cref="IHealthCheck.CheckHealthAsync" />
        public async Task <HealthCheckResult> CheckHealthAsync(
            HealthCheckContext context,
            CancellationToken cancellationToken = default)
        {
            Check.NotNull(context, nameof(context));

            if (await _service.CheckIsHealthyAsync(MaxMessageAge).ConfigureAwait(false))
            {
                return(new HealthCheckResult(HealthStatus.Healthy));
            }

            string errorMessage = "The outbound queue exceeded the configured limits " +
                                  $"(max message age: {MaxMessageAge.ToString()}, " +
                                  $"max queue length: {MaxQueueLength?.ToString(CultureInfo.InvariantCulture) ?? "-"}).";

            return(new HealthCheckResult(context.Registration.FailureStatus, errorMessage));
        }