Skip to content

Commit e0d8204

Browse files
committed
Add _MS suffix to retry constants.
1 parent 2f8dafe commit e0d8204

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/cargo/util/network/retry.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ pub enum RetryResult<T> {
2020
}
2121

2222
/// Maximum amount of time a single retry can be delayed (milliseconds).
23-
const MAX_RETRY_SLEEP: u64 = 10 * 1000;
23+
const MAX_RETRY_SLEEP_MS: u64 = 10 * 1000;
2424
/// The minimum initial amount of time a retry will be delayed (milliseconds).
2525
///
2626
/// The actual amount of time will be a random value above this.
27-
const INITIAL_RETRY_SLEEP_BASE: u64 = 500;
27+
const INITIAL_RETRY_SLEEP_BASE_MS: u64 = 500;
2828
/// The maximum amount of additional time the initial retry will take (milliseconds).
2929
///
30-
/// The initial delay will be [`INITIAL_RETRY_SLEEP_BASE`] plus a random range
30+
/// The initial delay will be [`INITIAL_RETRY_SLEEP_BASE_MS`] plus a random range
3131
/// from 0 to this value.
32-
const INITIAL_RETRY_JITTER: u64 = 1000;
32+
const INITIAL_RETRY_JITTER_MS: u64 = 1000;
3333

3434
impl<'a> Retry<'a> {
3535
pub fn new(config: &'a Config) -> CargoResult<Retry<'a>> {
@@ -55,11 +55,11 @@ impl<'a> Retry<'a> {
5555
self.retries += 1;
5656
let sleep = if self.retries == 1 {
5757
let mut rng = rand::thread_rng();
58-
INITIAL_RETRY_SLEEP_BASE + rng.gen_range(0..INITIAL_RETRY_JITTER)
58+
INITIAL_RETRY_SLEEP_BASE_MS + rng.gen_range(0..INITIAL_RETRY_JITTER_MS)
5959
} else {
6060
min(
61-
((self.retries - 1) * 3) * 1000 + INITIAL_RETRY_SLEEP_BASE,
62-
MAX_RETRY_SLEEP,
61+
((self.retries - 1) * 3) * 1000 + INITIAL_RETRY_SLEEP_BASE_MS,
62+
MAX_RETRY_SLEEP_MS,
6363
)
6464
};
6565
RetryResult::Retry(sleep)
@@ -208,8 +208,8 @@ fn default_retry_schedule() {
208208
match retry.r#try(|| spurious()) {
209209
RetryResult::Retry(sleep) => {
210210
assert!(
211-
sleep >= INITIAL_RETRY_SLEEP_BASE
212-
&& sleep < INITIAL_RETRY_SLEEP_BASE + INITIAL_RETRY_JITTER
211+
sleep >= INITIAL_RETRY_SLEEP_BASE_MS
212+
&& sleep < INITIAL_RETRY_SLEEP_BASE_MS + INITIAL_RETRY_JITTER_MS
213213
);
214214
}
215215
_ => panic!("unexpected non-retry"),

0 commit comments

Comments
 (0)