pub struct RPCEndpoint {
pub url: Url,
pub bearer_header: Option<String>,
pub retries: u8,
pub retry_method: RetryMethod,
}Expand description
Configuration for a NEAR RPC endpoint with retry and backoff settings.
Fields§
§url: UrlThe URL of the RPC endpoint
bearer_header: Option<String>Optional API key for authenticated requests
retries: u8Number of consecutive failures to move on to the next endpoint.
retry_method: RetryMethodThe retry method to use
Implementations§
Source§impl RPCEndpoint
impl RPCEndpoint
Sourcepub const fn new(url: Url) -> Self
pub const fn new(url: Url) -> Self
Constructs a new RPC endpoint configuration with default settings.
The default retry method is ExponentialBackoff with an initial sleep of 10ms and a factor of 2.
The delays will be 10ms, 20ms, 40ms, 80ms, 160ms.
Sourcepub fn with_api_key(self, api_key: String) -> Self
pub fn with_api_key(self, api_key: String) -> Self
Set API key for the endpoint.
Sourcepub const fn with_retries(self, retries: u8) -> Self
pub const fn with_retries(self, retries: u8) -> Self
Set number of retries for the endpoint before moving on to the next one.
pub const fn with_retry_method(self, retry_method: RetryMethod) -> Self
pub fn get_sleep_duration(&self, retry: usize) -> Duration
pub(crate) fn client(&self) -> Result<Client, InvalidHeaderValue>
Trait Implementations§
Source§impl Clone for RPCEndpoint
impl Clone for RPCEndpoint
Source§fn clone(&self) -> RPCEndpoint
fn clone(&self) -> RPCEndpoint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RPCEndpoint
impl Debug for RPCEndpoint
Source§impl<'de> Deserialize<'de> for RPCEndpoint
impl<'de> Deserialize<'de> for RPCEndpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RPCEndpoint
impl RefUnwindSafe for RPCEndpoint
impl Send for RPCEndpoint
impl Sync for RPCEndpoint
impl Unpin for RPCEndpoint
impl UnwindSafe for RPCEndpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more