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,8 +25,13 @@ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, si
2525 // retry small number of known errors
2626 return ERetryErrorClass::ShortRetry;
2727 default :
28- // do not retry others
29- return ERetryErrorClass::NoRetry;
28+ if (options.ExtendedRetriedCodes .contains (curlCode)) {
29+ // retry explicitly enumerated codes
30+ return ERetryErrorClass::ShortRetry;
31+ } else {
32+ // do not retry others
33+ return ERetryErrorClass::NoRetry;
34+ }
3035 }
3136
3237 switch (httpCode) {
@@ -48,8 +53,12 @@ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, si
4853 TDuration::MilliSeconds (10 ), // minDelay
4954 TDuration::MilliSeconds (200 ), // minLongRetryDelay
5055 TDuration::Seconds (30 ), // maxDelay
51- maxRetries, // maxRetries
52- maxTime); // maxTime
56+ options.MaxRetries , // maxRetries
57+ options.MaxTime ); // maxTime
58+ }
59+
60+ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy (TDuration maxTime, size_t maxRetries) {
61+ return GetHTTPDefaultRetryPolicy (THttpRetryPolicyOptions{.MaxTime = maxTime, .MaxRetries = maxRetries});
5362}
5463
5564}
0 commit comments