pub struct RpcEndpoint {
pub name: String,
pub url: String,
pub healthy: bool,
pub last_check: Instant,
pub cooldown_until: Option<Instant>,
pub cooldown_attempts: u32,
pub rate_limit_per_sec: u32,
pub burst_size: u32,
pub weight: u32,
pub metrics: Arc<EndpointMetrics>,
}Expand description
Represents the state and configuration of a single upstream JSON-RPC endpoint.
Fields§
§name: StringThe name of the endpoint for identification
url: StringThe URL of the RPC endpoint.
healthy: boolWhether the endpoint is currently considered healthy based on the last health check.
last_check: InstantThe timestamp of the last health check.
cooldown_until: Option<Instant>If the endpoint is in cooldown, this holds the time until it is available again.
cooldown_attempts: u32The number of times this endpoint has been put into cooldown. Used for exponential backoff.
rate_limit_per_sec: u32The configured rate limit in requests per second.
burst_size: u32The configured burst size for the rate limiter.
weight: u32The manual priority weight assigned to this endpoint. Higher is better.
metrics: Arc<EndpointMetrics>A shared, atomically updatable struct for tracking performance metrics.
Implementations§
Source§impl RpcEndpoint
impl RpcEndpoint
Sourcepub fn is_in_cooldown(&self) -> bool
pub fn is_in_cooldown(&self) -> bool
Returns true if the endpoint is currently in a cooldown period.
Sourcepub fn cooldown_remaining_secs(&self) -> i64
pub fn cooldown_remaining_secs(&self) -> i64
Returns the number of seconds remaining in the cooldown period. Returns 0 if the endpoint is not in cooldown.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Returns true if the endpoint is healthy and not in cooldown.
This is the primary check to determine if an endpoint can be used.
Trait Implementations§
Source§impl Clone for RpcEndpoint
impl Clone for RpcEndpoint
Source§fn clone(&self) -> RpcEndpoint
fn clone(&self) -> RpcEndpoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more