Ejemplo n.º 1
0
        /// <summary>
        /// 不断重试(有等待时间,无重试次数限制)
        /// </summary>
        /// <param name="response"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static EventLogEntry RetryForever(this EventResponse response)
        {
            var @event          = Hummingbird.Extensions.EventBus.Models.EventLogEntry.Clone(response);
            var numberOfRetries = response.GetNumberOfRetries();

            @event.WithRetry(0, ++numberOfRetries);
            return(@event);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 不断重试(有等待时间,无重试次数限制)
        /// </summary>
        /// <param name="response"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static EventLogEntry WaitAndRetryForever(this EventResponse response, Func <int, int> retryAttempt)
        {
            var numberOfRetries = response.GetNumberOfRetries();
            var ttl             = retryAttempt(numberOfRetries);
            var @event          = Hummingbird.Extensions.EventBus.Models.EventLogEntry.Clone(response);

            @event.WithWait(ttl);
            @event.WithRetry(0, ++numberOfRetries);
            return(@event);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 重试,(有等待时间,有重试次数限制)
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        public static EventLogEntry WaitAndRetry(this EventResponse response, int TTL, int maxRetries)
        {
            var @event          = Hummingbird.Extensions.EventBus.Models.EventLogEntry.Clone(response);
            var numberOfRetries = response.GetNumberOfRetries();

            //当前重试次数小于最大重试次数
            if (numberOfRetries < maxRetries)
            {
                @event.WithWait(TTL);
                @event.WithRetry(maxRetries, ++numberOfRetries);
            }
            else
            {
                @event.WithNoRetry();
            }

            return(@event);
        }