Skip to content

Commit 8f0af50

Browse files
tottotosylvestre
authored andcommitted
chore: replace retry crate with backon
1 parent 53a83e1 commit 8f0af50

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ strip = true
2727
anyhow = { version = "1.0", features = ["backtrace"] }
2828
ar = "0.9"
2929
async-trait = "0.1"
30+
backon = { version = "1", default-features = false, features = [
31+
"std-blocking-sleep",
32+
] }
3033
base64 = "0.21"
3134
bincode = "1"
3235
blake3 = "1"
@@ -78,7 +81,6 @@ reqwest = { version = "0.12", features = [
7881
"rustls-tls-native-roots",
7982
"trust-dns",
8083
], optional = true }
81-
retry = "2"
8284
semver = "1.0"
8385
serde = { version = "1.0", features = ["derive"] }
8486
serde_json = "1.0"

src/client.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::errors::*;
1616
use crate::net::Connection;
1717
use crate::protocol::{Request, Response};
1818
use crate::util;
19+
use backon::BlockingRetryable;
1920
use byteorder::{BigEndian, ByteOrder};
20-
use retry::{delay::Fixed, retry};
2121
use std::io::{self, BufReader, BufWriter, Read};
2222

2323
/// A connection to an sccache server.
@@ -79,7 +79,10 @@ pub fn connect_with_retry(addr: &crate::net::SocketAddr) -> io::Result<ServerCon
7979
// if the process exited.
8080
// * Send a pipe handle to the server process so it can notify
8181
// us once it starts the server instead of us polling.
82-
match retry(Fixed::from_millis(500).take(10), || connect_to_server(addr)) {
82+
let backoff = backon::ConstantBuilder::default()
83+
.with_delay(std::time::Duration::from_millis(500))
84+
.with_max_times(10);
85+
match (|| connect_to_server(addr)).retry(backoff).call() {
8386
Ok(conn) => Ok(conn),
8487
Err(e) => Err(io::Error::new(
8588
io::ErrorKind::TimedOut,

0 commit comments

Comments
 (0)