Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transports): add retries to HTTP transport #715

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -28,6 +28,7 @@ serde = { version = "1.0.90", features = ["derive"] }
serde_json = "1.0.39"
tiny-keccak = { version = "2.0.1", features = ["keccak"] }
pin-project = "1.0"
chrono = "0.4.31"
# Optional deps
secp256k1 = { version = "0.28", features = ["recovery"], optional = true }
once_cell = { version = "1.8.0", optional = true }
Expand Down
14 changes: 14 additions & 0 deletions src/error.rs
Expand Up @@ -16,6 +16,20 @@ pub enum TransportError {
/// Arbitrary, developer-readable description of the occurred error.
#[display(fmt = "{}", _0)]
Message(String),
/// Recoverable rate limit error.
#[display(fmt = "rate limit: {}", _0)]
RateLimit(RateLimit),
}

/// Recoverable rate limit error.
#[derive(Display, Debug, Clone, PartialEq)]
pub enum RateLimit {
/// Retry-After: <http-date>
#[display(fmt = "retry after date {}", _0)]
Date(String),
/// Retry-After: <delay-seconds>
#[display(fmt = "retry after number of seconds {}", _0)]
Seconds(u64),
}

/// Errors which can occur when attempting to generate resource uri.
Expand Down