Exemplo n.º 1
0
 EndpointHealthResult(BusHealthStatus status, IReceiveEndpoint receiveEndpoint, string description = null, Exception exception = null)
 {
     Status          = status;
     ReceiveEndpoint = receiveEndpoint;
     Description     = description;
     Exception       = exception;
 }
Exemplo n.º 2
0
 HealthResult(BusHealthStatus status, string description, Exception exception, IReadOnlyDictionary <string, EndpointHealthResult> endpoints)
 {
     Status      = status;
     Description = description;
     Exception   = exception;
     Endpoints   = endpoints;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 初始化一个<see cref="HealthResult"/>类型的实例
 /// </summary>
 /// <param name="status">业务健康状态</param>
 /// <param name="description">描述</param>
 /// <param name="exception">异常</param>
 /// <param name="data">数据</param>
 private HealthResult(BusHealthStatus status, string description = null, Exception exception = null, IReadOnlyDictionary <string, object> data = null)
 {
     Status      = status;
     Description = description;
     Exception   = exception;
     Data        = data ?? _emptyReadOnlyDictionary;
 }
Exemplo n.º 4
0
 public static Task <BusHealthStatus[]> WaitForHealthStatus(this IEnumerable <IBusHealth> healthChecks, BusHealthStatus expectedStatus,
                                                            CancellationToken cancellationToken)
 {
     return(Task.WhenAll(healthChecks.Select(healthCheck => WaitForHealthStatus(healthCheck, expectedStatus, cancellationToken))));
 }
Exemplo n.º 5
0
        public static async Task <BusHealthStatus> WaitForHealthStatus(this IBusHealth healthChecks, BusHealthStatus expectedStatus,
                                                                       CancellationToken cancellationToken)
        {
            var result = healthChecks.CheckHealth();

            while (result.Status != expectedStatus)
            {
                cancellationToken.ThrowIfCancellationRequested();

                await Task.Delay(100, cancellationToken).ConfigureAwait(false);

                result = healthChecks.CheckHealth();
            }

            return(result.Status);
        }
Exemplo n.º 6
0
 public static Task <BusHealthStatus[]> WaitForHealthStatus(this IEnumerable <IBusHealth> healthChecks, BusHealthStatus expectedStatus, TimeSpan timeout)
 {
     return(Task.WhenAll(healthChecks.Select(healthCheck => WaitForHealthStatus(healthCheck, expectedStatus, timeout))));
 }
Exemplo n.º 7
0
        public static async Task <BusHealthStatus> WaitForHealthStatus(this IBusHealth healthChecks, BusHealthStatus expectedStatus, TimeSpan timeout)
        {
            var expiresAt = DateTime.UtcNow + timeout;

            var result = healthChecks.CheckHealth();

            while (result.Status != expectedStatus)
            {
                if (DateTime.UtcNow >= expiresAt)
                {
                    return(result.Status);
                }

                await Task.Delay(100).ConfigureAwait(false);

                result = healthChecks.CheckHealth();
            }

            return(result.Status);
        }