pub struct CorrosionPooledClient { /* private fields */ }Expand description
Client to connect to a pool of Corrosion nodes.
Selects the first address from the list and tries to connect to it.
On I/O errors the client falls back to the next address; once a request succeeds the client
“sticks” to that peer until it has been failing continuously for the
configured stickiness_timeout.
Implementations§
Source§impl CorrosionPooledClient
impl CorrosionPooledClient
Sourcepub fn new(
addrs: Vec<String>,
stickiness_timeout: Duration,
resolver: Resolver<TokioRuntimeProvider>,
) -> Self
pub fn new( addrs: Vec<String>, stickiness_timeout: Duration, resolver: Resolver<TokioRuntimeProvider>, ) -> Self
Build a new pooled client.
addrs— ordered list of agent addresses. Each entry can be either ahost:portstring (resolved throughresolver) or an already resolvedSocketAddrformatted as a string. Entries are tried in the supplied order; once a peer has been successful the client prefers it for as long as it stays healthy.stickiness_timeout— how long the client keeps retrying a previously successful peer after it starts failing before rotating to the next address.resolver— DNS resolver used to translate hostnames to addresses.
Sourcepub async fn query_typed<T: DeserializeOwned + Unpin>(
&self,
statement: &Statement,
timeout: Option<u64>,
) -> Result<QueryStream<T>, Error>
pub async fn query_typed<T: DeserializeOwned + Unpin>( &self, statement: &Statement, timeout: Option<u64>, ) -> Result<QueryStream<T>, Error>
Run a one-shot query against the currently selected peer.
Equivalent to CorrosionApiClient::query_typed
Sourcepub async fn subscribe_typed<T: DeserializeOwned + Unpin>(
&self,
statement: &Statement,
skip_rows: bool,
from: Option<ChangeId>,
) -> Result<SubscriptionStream<T>, Error>
pub async fn subscribe_typed<T: DeserializeOwned + Unpin>( &self, statement: &Statement, skip_rows: bool, from: Option<ChangeId>, ) -> Result<SubscriptionStream<T>, Error>
Open a new subscription against the currently selected peer.
Sourcepub async fn subscription_typed<T: DeserializeOwned + Unpin>(
&self,
id: Uuid,
skip_rows: bool,
from: Option<ChangeId>,
) -> Result<SubscriptionStream<T>, Error>
pub async fn subscription_typed<T: DeserializeOwned + Unpin>( &self, id: Uuid, skip_rows: bool, from: Option<ChangeId>, ) -> Result<SubscriptionStream<T>, Error>
Reconnect to an existing subscription by id against the currently
selected peer. See CorrosionApiClient::subscription_typed.
Trait Implementations§
Source§impl Clone for CorrosionPooledClient
impl Clone for CorrosionPooledClient
Source§fn clone(&self) -> CorrosionPooledClient
fn clone(&self) -> CorrosionPooledClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CorrosionPooledClient
impl !RefUnwindSafe for CorrosionPooledClient
impl Send for CorrosionPooledClient
impl Sync for CorrosionPooledClient
impl Unpin for CorrosionPooledClient
impl UnsafeUnpin for CorrosionPooledClient
impl !UnwindSafe for CorrosionPooledClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more