Skip to content

Commit 6a80dc2

Browse files
committed
RSCBC-87: Remove retries from public API
Motivation ---------- The current state of the retry RFC does not really achieve functionality that users wants. Retries are also one of the most difficult parts of our API to design. For now we should remove support from the public API but leave functionality in core so that we behave the same as other SDKs for default retry behaviours. Changes ------- Remove retries from public API.
1 parent 31de57c commit 6a80dc2

21 files changed

+172
-766
lines changed

sdk/couchbase/src/clients/bucket_mgmt_client.rs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,8 @@ impl CouchbaseBucketMgmtClient {
135135
opts: GetAllBucketsOptions,
136136
) -> error::Result<Vec<BucketSettings>> {
137137
let agent = self.agent_provider.get_agent().await;
138-
let opts = couchbase_core::mgmtoptions::GetAllBucketsOptions::new().retry_strategy(
139-
opts.retry_strategy
140-
.clone()
141-
.unwrap_or(self.default_retry_strategy.clone()),
142-
);
138+
let opts = couchbase_core::mgmtoptions::GetAllBucketsOptions::new()
139+
.retry_strategy(self.default_retry_strategy.clone());
143140

144141
let buckets = agent.get_all_buckets(&opts).await?;
145142

@@ -152,11 +149,8 @@ impl CouchbaseBucketMgmtClient {
152149
opts: GetBucketOptions,
153150
) -> error::Result<BucketSettings> {
154151
let agent = self.agent_provider.get_agent().await;
155-
let opts = couchbase_core::mgmtoptions::GetBucketOptions::new(&bucket_name).retry_strategy(
156-
opts.retry_strategy
157-
.clone()
158-
.unwrap_or(self.default_retry_strategy.clone()),
159-
);
152+
let opts = couchbase_core::mgmtoptions::GetBucketOptions::new(&bucket_name)
153+
.retry_strategy(self.default_retry_strategy.clone());
160154

161155
let bucket = agent.get_bucket(&opts).await?;
162156

@@ -231,11 +225,7 @@ impl CouchbaseBucketMgmtClient {
231225

232226
let opts =
233227
couchbase_core::mgmtoptions::CreateBucketOptions::new(&settings.name, &core_settings)
234-
.retry_strategy(
235-
opts.retry_strategy
236-
.clone()
237-
.unwrap_or(self.default_retry_strategy.clone()),
238-
);
228+
.retry_strategy(self.default_retry_strategy.clone());
239229

240230
agent.create_bucket(&opts).await?;
241231

@@ -306,11 +296,7 @@ impl CouchbaseBucketMgmtClient {
306296

307297
let opts =
308298
couchbase_core::mgmtoptions::UpdateBucketOptions::new(&settings.name, &core_settings)
309-
.retry_strategy(
310-
opts.retry_strategy
311-
.clone()
312-
.unwrap_or(self.default_retry_strategy.clone()),
313-
);
299+
.retry_strategy(self.default_retry_strategy.clone());
314300

315301
agent.update_bucket(&opts).await?;
316302

@@ -324,11 +310,7 @@ impl CouchbaseBucketMgmtClient {
324310
) -> error::Result<()> {
325311
let agent = self.agent_provider.get_agent().await;
326312
let opts = couchbase_core::mgmtoptions::DeleteBucketOptions::new(&bucket_name)
327-
.retry_strategy(
328-
opts.retry_strategy
329-
.clone()
330-
.unwrap_or(self.default_retry_strategy.clone()),
331-
);
313+
.retry_strategy(self.default_retry_strategy.clone());
332314

333315
agent.delete_bucket(&opts).await?;
334316

@@ -342,11 +324,7 @@ impl CouchbaseBucketMgmtClient {
342324
) -> error::Result<()> {
343325
let agent = self.agent_provider.get_agent().await;
344326
let opts = couchbase_core::mgmtoptions::FlushBucketOptions::new(&bucket_name)
345-
.retry_strategy(
346-
opts.retry_strategy
347-
.clone()
348-
.unwrap_or(self.default_retry_strategy.clone()),
349-
);
327+
.retry_strategy(self.default_retry_strategy.clone());
350328
agent.flush_bucket(&opts).await?;
351329

352330
Ok(())

sdk/couchbase/src/clients/cluster_client.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use crate::clients::user_mgmt_client::{
1212
};
1313
use crate::error;
1414
use crate::options::cluster_options::ClusterOptions;
15-
use crate::retry::DEFAULT_RETRY_STRATEGY;
1615
use couchbase_connstr::{parse, resolve, Address, SrvRecord};
1716
use couchbase_core::agentoptions::{CompressionConfig, SeedConfig};
1817
use couchbase_core::ondemand_agentmanager::{OnDemandAgentManager, OnDemandAgentManagerOptions};
1918
use couchbase_core::retry::RetryStrategy;
19+
use couchbase_core::retrybesteffort::{BestEffortRetryStrategy, ExponentialBackoffCalculator};
2020
use std::collections::HashMap;
2121
use std::sync::Arc;
2222
use std::time::Duration;
@@ -149,10 +149,9 @@ impl CouchbaseClusterBackend {
149149
opts: ClusterOptions,
150150
extra_opts: HashMap<String, Vec<String>>,
151151
) -> error::Result<CouchbaseClusterBackend> {
152-
let default_retry_strategy = match &opts.retry_strategy {
153-
Some(r) => r.clone(),
154-
None => DEFAULT_RETRY_STRATEGY.clone(),
155-
};
152+
let default_retry_strategy = Arc::new(BestEffortRetryStrategy::new(
153+
ExponentialBackoffCalculator::default(),
154+
));
156155

157156
let tls_config = if let Some(tls_config) = opts.tls_options {
158157
Some(
@@ -237,7 +236,10 @@ impl CouchbaseClusterBackend {
237236
fn search_client(&self) -> CouchbaseSearchClient {
238237
let agent = self.agent_manager.get_cluster_agent();
239238

240-
CouchbaseSearchClient::new(CouchbaseAgentProvider::with_agent(agent.clone()))
239+
CouchbaseSearchClient::new(
240+
CouchbaseAgentProvider::with_agent(agent.clone()),
241+
self.default_retry_strategy.clone(),
242+
)
241243
}
242244

243245
fn merge_options(

sdk/couchbase/src/clients/collection_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl CouchbaseCollectionClient {
114114
scope_name: self.scope_name().to_string(),
115115
collection_name: self.name().to_string(),
116116
},
117+
self.default_retry_strategy.clone(),
117118
)
118119
}
119120
}

sdk/couchbase/src/clients/collections_mgmt_client.rs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,7 @@ impl CouchbaseCollectionsMgmtClient {
158158
&self.bucket_name,
159159
scope_name.into().as_str(),
160160
)
161-
.retry_strategy(
162-
opts.retry_strategy
163-
.clone()
164-
.unwrap_or(self.default_retry_strategy.clone()),
165-
),
161+
.retry_strategy(self.default_retry_strategy.clone()),
166162
)
167163
.await?;
168164

@@ -181,11 +177,7 @@ impl CouchbaseCollectionsMgmtClient {
181177
&self.bucket_name,
182178
scope_name.into().as_str(),
183179
)
184-
.retry_strategy(
185-
opts.retry_strategy
186-
.clone()
187-
.unwrap_or(self.default_retry_strategy.clone()),
188-
),
180+
.retry_strategy(self.default_retry_strategy.clone()),
189181
)
190182
.await?;
191183

@@ -207,11 +199,7 @@ impl CouchbaseCollectionsMgmtClient {
207199
scope_name.as_str(),
208200
collection_name.as_str(),
209201
)
210-
.retry_strategy(
211-
opts.retry_strategy
212-
.clone()
213-
.unwrap_or(self.default_retry_strategy.clone()),
214-
);
202+
.retry_strategy(self.default_retry_strategy.clone());
215203

216204
if let Some(max_ttl) = settings.max_expiry {
217205
opts = opts.max_ttl(max_ttl.into());
@@ -241,11 +229,7 @@ impl CouchbaseCollectionsMgmtClient {
241229
scope_name.as_str(),
242230
collection_name.as_str(),
243231
)
244-
.retry_strategy(
245-
opts.retry_strategy
246-
.clone()
247-
.unwrap_or(self.default_retry_strategy.clone()),
248-
);
232+
.retry_strategy(self.default_retry_strategy.clone());
249233

250234
if let Some(max_ttl) = settings.max_expiry {
251235
opts = opts.max_ttl(max_ttl.into());
@@ -274,11 +258,7 @@ impl CouchbaseCollectionsMgmtClient {
274258
scope_name.into().as_str(),
275259
collection_name.into().as_str(),
276260
)
277-
.retry_strategy(
278-
opts.retry_strategy
279-
.clone()
280-
.unwrap_or(self.default_retry_strategy.clone()),
281-
),
261+
.retry_strategy(self.default_retry_strategy.clone()),
282262
)
283263
.await?;
284264

@@ -290,11 +270,7 @@ impl CouchbaseCollectionsMgmtClient {
290270
let manifest = agent
291271
.get_collection_manifest(
292272
&couchbase_core::mgmtoptions::GetCollectionManifestOptions::new(&self.bucket_name)
293-
.retry_strategy(
294-
opts.retry_strategy
295-
.clone()
296-
.unwrap_or(self.default_retry_strategy.clone()),
297-
),
273+
.retry_strategy(self.default_retry_strategy.clone()),
298274
)
299275
.await?;
300276

0 commit comments

Comments
 (0)