Skip to content

Commit e6d8e57

Browse files
committed
Drop custom retry policy
We drop our (~broken) `RetryPolicy`, and replace it with the new-ish retry policy that is shipping in `reqwest` since 0.12.23.
1 parent 93b7381 commit e6d8e57

File tree

5 files changed

+42
-444
lines changed

5 files changed

+42
-444
lines changed

src/client.rs

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,39 @@ use crate::types::{
1111
DeleteObjectRequest, DeleteObjectResponse, GetObjectRequest, GetObjectResponse,
1212
ListKeyVersionsRequest, ListKeyVersionsResponse, PutObjectRequest, PutObjectResponse,
1313
};
14-
use crate::util::retry::{retry, RetryPolicy};
15-
1614
const APPLICATION_OCTET_STREAM: &str = "application/octet-stream";
1715
const DEFAULT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
1816
const DEFAULT_RETRIES: u32 = 2;
1917

2018
/// Thin-client to access a hosted instance of Versioned Storage Service (VSS).
2119
/// The provided [`VssClient`] API is minimalistic and is congruent to the VSS server-side API.
2220
#[derive(Clone)]
23-
pub struct VssClient<R>
24-
where
25-
R: RetryPolicy<E = VssError>,
26-
{
21+
pub struct VssClient {
2722
base_url: String,
2823
client: Client,
29-
retry_policy: R,
3024
header_provider: Arc<dyn VssHeaderProvider>,
3125
}
3226

33-
impl<R: RetryPolicy<E = VssError>> VssClient<R> {
27+
impl VssClient {
3428
/// Constructs a [`VssClient`] using `base_url` as the VSS server endpoint.
35-
pub fn new(base_url: String, retry_policy: R) -> Result<Self, VssError> {
29+
pub fn new(base_url: String) -> Result<Self, VssError> {
3630
let client = build_client(&base_url)?;
37-
Ok(Self::from_client(base_url, client, retry_policy))
31+
Ok(Self::from_client(base_url, client))
3832
}
3933

4034
/// Constructs a [`VssClient`] from a given [`reqwest::Client`], using `base_url` as the VSS server endpoint.
41-
pub fn from_client(base_url: String, client: Client, retry_policy: R) -> Self {
42-
Self {
43-
base_url,
44-
client,
45-
retry_policy,
46-
header_provider: Arc::new(FixedHeaders::new(HashMap::new())),
47-
}
35+
pub fn from_client(base_url: String, client: Client) -> Self {
36+
Self { base_url, client, header_provider: Arc::new(FixedHeaders::new(HashMap::new())) }
4837
}
4938

5039
/// Constructs a [`VssClient`] using `base_url` as the VSS server endpoint.
5140
///
5241
/// HTTP headers will be provided by the given `header_provider`.
5342
pub fn new_with_headers(
54-
base_url: String, retry_policy: R, header_provider: Arc<dyn VssHeaderProvider>,
43+
base_url: String, header_provider: Arc<dyn VssHeaderProvider>,
5544
) -> Result<Self, VssError> {
5645
let client = build_client(&base_url)?;
57-
Ok(Self { base_url, client, retry_policy, header_provider })
46+
Ok(Self { base_url, client, header_provider })
5847
}
5948

6049
/// Returns the underlying base URL.
@@ -68,22 +57,17 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
6857
pub async fn get_object(
6958
&self, request: &GetObjectRequest,
7059
) -> Result<GetObjectResponse, VssError> {
71-
retry(
72-
|| async {
73-
let url = format!("{}/getObject", self.base_url);
74-
self.post_request(request, &url).await.and_then(|response: GetObjectResponse| {
75-
if response.value.is_none() {
76-
Err(VssError::InternalServerError(
77-
"VSS Server API Violation, expected value in GetObjectResponse but found none".to_string(),
78-
))
79-
} else {
80-
Ok(response)
81-
}
82-
})
83-
},
84-
&self.retry_policy,
85-
)
86-
.await
60+
let url = format!("{}/getObject", self.base_url);
61+
self.post_request(request, &url).await.and_then(|response: GetObjectResponse| {
62+
if response.value.is_none() {
63+
Err(VssError::InternalServerError(
64+
"VSS Server API Violation, expected value in GetObjectResponse but found none"
65+
.to_string(),
66+
))
67+
} else {
68+
Ok(response)
69+
}
70+
})
8771
}
8872

8973
/// Writes multiple [`PutObjectRequest::transaction_items`] as part of a single transaction.
@@ -93,14 +77,8 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
9377
pub async fn put_object(
9478
&self, request: &PutObjectRequest,
9579
) -> Result<PutObjectResponse, VssError> {
96-
retry(
97-
|| async {
98-
let url = format!("{}/putObjects", self.base_url);
99-
self.post_request(request, &url).await
100-
},
101-
&self.retry_policy,
102-
)
103-
.await
80+
let url = format!("{}/putObjects", self.base_url);
81+
self.post_request(request, &url).await
10482
}
10583

10684
/// Deletes the given `key` and `value` in `request`.
@@ -109,14 +87,8 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
10987
pub async fn delete_object(
11088
&self, request: &DeleteObjectRequest,
11189
) -> Result<DeleteObjectResponse, VssError> {
112-
retry(
113-
|| async {
114-
let url = format!("{}/deleteObject", self.base_url);
115-
self.post_request(request, &url).await
116-
},
117-
&self.retry_policy,
118-
)
119-
.await
90+
let url = format!("{}/deleteObject", self.base_url);
91+
self.post_request(request, &url).await
12092
}
12193

12294
/// Lists keys and their corresponding version for a given [`ListKeyVersionsRequest::store_id`].
@@ -125,14 +97,8 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
12597
pub async fn list_key_versions(
12698
&self, request: &ListKeyVersionsRequest,
12799
) -> Result<ListKeyVersionsResponse, VssError> {
128-
retry(
129-
|| async {
130-
let url = format!("{}/listKeyVersions", self.base_url);
131-
self.post_request(request, &url).await
132-
},
133-
&self.retry_policy,
134-
)
135-
.await
100+
let url = format!("{}/listKeyVersions", self.base_url);
101+
self.post_request(request, &url).await
136102
}
137103

138104
async fn post_request<Rq: Message, Rs: Message + Default>(

src/util/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
/// [`StorableBuilder`]: storable_builder::StorableBuilder
44
pub mod storable_builder;
55

6-
/// Contains retry utilities.
7-
pub mod retry;
8-
96
/// Contains [`KeyObfuscator`] utility.
107
///
118
/// [`KeyObfuscator`]: key_obfuscator::KeyObfuscator

src/util/retry.rs

Lines changed: 0 additions & 245 deletions
This file was deleted.

0 commit comments

Comments
 (0)