Skip to content

Commit cd57e3c

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

File tree

5 files changed

+40
-441
lines changed

5 files changed

+40
-441
lines changed

src/client.rs

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,46 @@ 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

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

32-
impl<R: RetryPolicy<E = VssError>> VssClient<R> {
26+
impl VssClient {
3327
/// Constructs a [`VssClient`] using `base_url` as the VSS server endpoint.
34-
pub fn new(base_url: String, retry_policy: R) -> Self {
28+
pub fn new(base_url: String) -> Self {
3529
let client = Client::builder()
3630
.timeout(DEFAULT_TIMEOUT)
3731
.connect_timeout(DEFAULT_TIMEOUT)
3832
.read_timeout(DEFAULT_TIMEOUT)
3933
.build()
4034
.unwrap();
41-
Self::from_client(base_url, client, retry_policy)
35+
Self::from_client(base_url, client)
4236
}
4337

4438
/// Constructs a [`VssClient`] from a given [`reqwest::Client`], using `base_url` as the VSS server endpoint.
45-
pub fn from_client(base_url: String, client: Client, retry_policy: R) -> Self {
46-
Self {
47-
base_url,
48-
client,
49-
retry_policy,
50-
header_provider: Arc::new(FixedHeaders::new(HashMap::new())),
51-
}
39+
pub fn from_client(base_url: String, client: Client) -> Self {
40+
Self { base_url, client, header_provider: Arc::new(FixedHeaders::new(HashMap::new())) }
5241
}
5342

5443
/// Constructs a [`VssClient`] using `base_url` as the VSS server endpoint.
5544
///
5645
/// HTTP headers will be provided by the given `header_provider`.
57-
pub fn new_with_headers(
58-
base_url: String, retry_policy: R, header_provider: Arc<dyn VssHeaderProvider>,
59-
) -> Self {
46+
pub fn new_with_headers(base_url: String, header_provider: Arc<dyn VssHeaderProvider>) -> Self {
6047
let client = Client::builder()
6148
.timeout(DEFAULT_TIMEOUT)
6249
.connect_timeout(DEFAULT_TIMEOUT)
6350
.read_timeout(DEFAULT_TIMEOUT)
6451
.build()
6552
.unwrap();
66-
Self { base_url, client, retry_policy, header_provider }
53+
Self { base_url, client, header_provider }
6754
}
6855

6956
/// Returns the underlying base URL.
@@ -77,22 +64,17 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
7764
pub async fn get_object(
7865
&self, request: &GetObjectRequest,
7966
) -> Result<GetObjectResponse, VssError> {
80-
retry(
81-
|| async {
82-
let url = format!("{}/getObject", self.base_url);
83-
self.post_request(request, &url).await.and_then(|response: GetObjectResponse| {
84-
if response.value.is_none() {
85-
Err(VssError::InternalServerError(
86-
"VSS Server API Violation, expected value in GetObjectResponse but found none".to_string(),
87-
))
88-
} else {
89-
Ok(response)
90-
}
91-
})
92-
},
93-
&self.retry_policy,
94-
)
95-
.await
67+
let url = format!("{}/getObject", self.base_url);
68+
self.post_request(request, &url).await.and_then(|response: GetObjectResponse| {
69+
if response.value.is_none() {
70+
Err(VssError::InternalServerError(
71+
"VSS Server API Violation, expected value in GetObjectResponse but found none"
72+
.to_string(),
73+
))
74+
} else {
75+
Ok(response)
76+
}
77+
})
9678
}
9779

9880
/// Writes multiple [`PutObjectRequest::transaction_items`] as part of a single transaction.
@@ -102,14 +84,8 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
10284
pub async fn put_object(
10385
&self, request: &PutObjectRequest,
10486
) -> Result<PutObjectResponse, VssError> {
105-
retry(
106-
|| async {
107-
let url = format!("{}/putObjects", self.base_url);
108-
self.post_request(request, &url).await
109-
},
110-
&self.retry_policy,
111-
)
112-
.await
87+
let url = format!("{}/putObjects", self.base_url);
88+
self.post_request(request, &url).await
11389
}
11490

11591
/// Deletes the given `key` and `value` in `request`.
@@ -118,14 +94,8 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
11894
pub async fn delete_object(
11995
&self, request: &DeleteObjectRequest,
12096
) -> Result<DeleteObjectResponse, VssError> {
121-
retry(
122-
|| async {
123-
let url = format!("{}/deleteObject", self.base_url);
124-
self.post_request(request, &url).await
125-
},
126-
&self.retry_policy,
127-
)
128-
.await
97+
let url = format!("{}/deleteObject", self.base_url);
98+
self.post_request(request, &url).await
12999
}
130100

131101
/// Lists keys and their corresponding version for a given [`ListKeyVersionsRequest::store_id`].
@@ -134,14 +104,8 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
134104
pub async fn list_key_versions(
135105
&self, request: &ListKeyVersionsRequest,
136106
) -> Result<ListKeyVersionsResponse, VssError> {
137-
retry(
138-
|| async {
139-
let url = format!("{}/listKeyVersions", self.base_url);
140-
self.post_request(request, &url).await
141-
},
142-
&self.retry_policy,
143-
)
144-
.await
107+
let url = format!("{}/listKeyVersions", self.base_url);
108+
self.post_request(request, &url).await
145109
}
146110

147111
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

0 commit comments

Comments
 (0)