-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add retry behavior for package cache downloads (#280)
* fix: add retry for package cache * feat: add retry policy crate * test: add a test to verify the retry behavior
- Loading branch information
1 parent
5c9f1e8
commit c462253
Showing
6 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! Reexports the trait [`RetryPolicy`] from the `retry_policies` crate as well as all | ||
//! implementations. | ||
//! | ||
//! This module also provides the [`DoNotRetryPolicy`] which is useful if you do not want to retry | ||
//! anything. | ||
|
||
pub use retry_policies::{policies::*, Jitter, RetryDecision, RetryPolicy}; | ||
|
||
/// A simple [`RetryPolicy`] that just never retries. | ||
pub struct DoNotRetryPolicy; | ||
impl RetryPolicy for DoNotRetryPolicy { | ||
fn should_retry(&self, _: u32) -> RetryDecision { | ||
RetryDecision::DoNotRetry | ||
} | ||
} | ||
|
||
/// Returns the default retry policy that can be used . | ||
/// | ||
/// This is useful if you just do not care about a retry policy and you just want something | ||
/// sensible. Note that the behavior of what is "sensible" might change over time. | ||
pub fn default_retry_policy() -> ExponentialBackoff { | ||
ExponentialBackoff::builder().build_with_max_retries(3) | ||
} |