22
33namespace NYql {
44
5- IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy (TDuration maxTime, size_t maxRetries ) {
6- if (!maxTime ) {
7- maxTime = TDuration::Minutes (5 );
5+ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy (THttpRetryPolicyOptions&& options ) {
6+ if (!options. MaxTime ) {
7+ options. MaxTime = TDuration::Minutes (5 );
88 }
9- return IHTTPGateway::TRetryPolicy::GetExponentialBackoffPolicy ([](CURLcode curlCode, long httpCode) {
9+ return IHTTPGateway::TRetryPolicy::GetExponentialBackoffPolicy ([options ](CURLcode curlCode, long httpCode) {
1010
1111 switch (curlCode) {
1212 case CURLE_OK:
@@ -25,6 +25,10 @@ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, si
2525 // retry small number of known errors
2626 return ERetryErrorClass::ShortRetry;
2727 default :
28+ if (options.ExtendedRetriedCodes .contains (curlCode)) {
29+ // retry explicitly enumerated codes
30+ return ERetryErrorClass::ShortRetry;
31+ }
2832 // do not retry others
2933 return ERetryErrorClass::NoRetry;
3034 }
@@ -48,8 +52,12 @@ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, si
4852 TDuration::MilliSeconds (10 ), // minDelay
4953 TDuration::MilliSeconds (200 ), // minLongRetryDelay
5054 TDuration::Seconds (30 ), // maxDelay
51- maxRetries, // maxRetries
52- maxTime); // maxTime
55+ options.MaxRetries , // maxRetries
56+ options.MaxTime ); // maxTime
57+ }
58+
59+ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy (TDuration maxTime, size_t maxRetries) {
60+ return GetHTTPDefaultRetryPolicy (THttpRetryPolicyOptions{.MaxTime = maxTime, .MaxRetries = maxRetries});
5361}
5462
5563}
0 commit comments