@@ -117,6 +117,7 @@ mod multi_search;
117117mod operations;
118118mod preset;
119119mod presets;
120+ mod retry_policy;
120121mod stemming;
121122mod stopword;
122123mod stopwords;
@@ -137,6 +138,7 @@ use keys::Keys;
137138use operations:: Operations ;
138139use preset:: Preset ;
139140use presets:: Presets ;
141+ use retry_policy:: ClientRetryPolicy ;
140142use stemming:: Stemming ;
141143use stopword:: Stopword ;
142144use stopwords:: Stopwords ;
@@ -373,9 +375,9 @@ impl Client {
373375 #[ builder( default = Duration :: from_secs( 60 ) ) ]
374376 /// The duration after which an unhealthy node will be retried for requests.
375377 healthcheck_interval : Duration ,
376- #[ builder( default = ExponentialBackoff :: builder ( ) . build_with_max_retries ( 3 ) ) ]
378+ #[ builder( into , default ) ]
377379 /// The retry policy for transient network errors on a *single* node.
378- retry_policy : ExponentialBackoff ,
380+ retry_policy : ClientRetryPolicy ,
379381 ) -> Result < Self , & ' static str > {
380382 let is_nearest_node_set = nearest_node. is_some ( ) ;
381383
@@ -397,11 +399,19 @@ impl Client {
397399 let http_client = builder. build ( ) . expect ( "Failed to build reqwest client" ) ;
398400
399401 #[ cfg( not( target_arch = "wasm32" ) ) ]
400- let http_client = ReqwestMiddlewareClientBuilder :: new (
402+ let mw_builder = ReqwestMiddlewareClientBuilder :: new (
401403 builder. build ( ) . expect ( "Failed to build reqwest client" ) ,
402- )
403- . with ( RetryTransientMiddleware :: new_with_policy ( retry_policy) )
404- . build ( ) ;
404+ ) ;
405+
406+ #[ cfg( not( target_arch = "wasm32" ) ) ]
407+ let http_client = match retry_policy {
408+ ClientRetryPolicy :: Default ( policy) => mw_builder
409+ . with ( RetryTransientMiddleware :: new_with_policy ( policy) )
410+ . build ( ) ,
411+ ClientRetryPolicy :: Timed ( policy) => mw_builder
412+ . with ( RetryTransientMiddleware :: new_with_policy ( policy) )
413+ . build ( ) ,
414+ } ;
405415
406416 let mut url = node_config. url ;
407417 if url. len ( ) > 1 && matches ! ( url. chars( ) . last( ) , Some ( '/' ) ) {
0 commit comments