public static TransformOutcome <OUTPUT_MODEL> DefaultRetryHandle429 <OUTPUT_MODEL>(int retryCount, IRestResponse response) { if (response.StatusCode == HttpStatusCode.TooManyRequests) { if (retryCount >= defaultAttempts) { return(Abort.From($"Response HTTP status was still {response.StatusCode} after {defaultAttempts} attempts.")); } else { return(Retry.From(TimeSpan.FromMilliseconds(defaultBackoffTimes[retryCount]))); } } return(new Next("Not 429")); }
public static TransformOutcome <OUTPUT_MODEL> DefaultHandleHttpStatus5xx <OUTPUT_MODEL>( int retryCount, IRestResponse response) { if ((int)response.StatusCode >= 500 && (int)response.StatusCode <= 599) { if (retryCount >= defaultAttempts) { return(Abort.From($"Response HTTP status was still {response.StatusCode} after {defaultAttempts} attempts.")); } else { return(Retry.From(TimeSpan.FromMilliseconds(defaultBackoffTimes[retryCount]))); } } return(new Next("Not 5xx")); }
public static TransformOutcome <OUTPUT_MODEL> DefaultHandleTransportError <OUTPUT_MODEL>(int retryCount, IRestResponse response) { const int attempts = 10; if (response.ResponseStatus != ResponseStatus.Completed) { if (retryCount >= attempts) { return(Abort.From( $"Transport error. ResponseStatus was still {response.ResponseStatus} after {attempts} attempts. " + $"restSharp error message: {response.ErrorMessage}")); } else { return(Retry.From(TimeSpan.FromMilliseconds(0))); } } return(new Next("Not TransportError")); }