#[non_exhaustive]pub struct ClientConfig {
pub graphql_uri: String,
pub retries: u32,
pub retry_delay: Duration,
pub timeout: Duration,
pub max_retry_after: Duration,
}Expand description
Configuration for the Archive Node client.
#[non_exhaustive], so build it from ClientConfig::default and the
setters rather than with a struct literal:
use std::time::Duration;
use mina_archive_sdk::ClientConfig;
let config = ClientConfig::new("https://archive.example/")
.attempts(5)
.timeout(Duration::from_secs(60));The schema gains fields under a minor server release, so anything the caller may need to configure later has to be addable without a major here.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.graphql_uri: StringGraphQL endpoint URL.
retries: u32Total number of attempts, including the initial try — retries: 5
means five requests, not one plus five. Must be ≥ 1.
Prefer ClientConfig::attempts, which says so in its name.
retry_delay: DurationDelay between attempts.
timeout: DurationPer-request HTTP timeout.
max_retry_after: DurationCeiling on a server-supplied retry-after wait.
ClientConfig::timeout bounds one HTTP request; it does not
cover the sleep between attempts, so without a ceiling a retry-after
of 86400 parks the call for a day. When the server asks for longer than
this, the call gives up at once and returns Error::RateLimited
carrying the requested delay, so the caller decides what to do.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(graphql_uri: impl Into<String>) -> Self
pub fn new(graphql_uri: impl Into<String>) -> Self
Default configuration pointed at graphql_uri.
Sourcepub fn graphql_uri(self, uri: impl Into<String>) -> Self
pub fn graphql_uri(self, uri: impl Into<String>) -> Self
Set the endpoint URL.
Sourcepub fn attempts(self, attempts: u32) -> Self
pub fn attempts(self, attempts: u32) -> Self
Set the total number of attempts, including the first one.
attempts(1) disables retrying. Values below 1 are raised to 1.
Sourcepub fn retry_delay(self, delay: Duration) -> Self
pub fn retry_delay(self, delay: Duration) -> Self
Set the delay between attempts.
Sourcepub fn max_retry_after(self, max: Duration) -> Self
pub fn max_retry_after(self, max: Duration) -> Self
Set the ceiling on a server-supplied retry-after wait.
Duration::ZERO never waits on retry-after: a 429 returns
Error::RateLimited on the first response.