pub struct Reader { /* private fields */ }Expand description
Per-connection reader. Owns the WebSocket transport and the connection-scoped symbol dictionary.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self>
pub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self>
Open a new connection from a connect string.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Open a new connection from the config string stored in the
QDB_CLIENT_CONF environment variable. Format matches Reader::from_conf.
Sourcepub fn from_config(cfg: &ReaderConfig) -> Result<Self>
pub fn from_config(cfg: &ReaderConfig) -> Result<Self>
Walk cfg.addrs via the per-client host-health tracker, opening
the highest-priority unattempted endpoint and eagerly consuming
the SERVER_INFO frame. Accepts the first endpoint whose role
matches cfg.target. Returns:
RoleMismatchif every endpoint connected but none advertised a matching role (last-seen role surfaced in the message).AuthErrorif at least one endpoint 401/403’d and every other endpoint failed too (per-endpoint accumulation lets the message name every endpoint that rejected credentials).SocketErrorif every endpoint failed at the transport layer (refused / timed out / TLS error / etc.).- whatever the last attempt returned otherwise.
The initial connect deliberately does not apply the egress
failover backoff schedule — it walks every address once and
reports back. Mid-query failover (via Cursor::next_batch) is
what uses failover_backoff_* to space retries.
The tracker is constructed fresh here, so every host starts at
Unknown state and the priority-based pick degenerates to the
user-supplied addr= order. From this Reader onward, the
tracker accumulates classifications across Executes per the
failover.md §2 priority lattice.
Sourcepub fn current_addr(&self) -> &Endpoint
pub fn current_addr(&self) -> &Endpoint
The endpoint this connection is currently bound to. Borrowed
from the configured address list, so the borrow lives as long
as &self. Stable across connect-string reorderings, unlike
the (deliberately not exposed) underlying address-list index.
Sourcepub fn bytes_received(&self) -> u64
pub fn bytes_received(&self) -> u64
Total wire bytes (frame header + payload) read off the transport since this connection was opened. Useful for benchmarking the effective throughput a query produces.
Sourcepub fn transport_torn_down(&self) -> bool
pub fn transport_torn_down(&self) -> bool
true when the underlying transport has been torn down (mid-stream
cursor abandonment, fatal socket error, role-mismatch failover that
couldn’t find a replacement). Pool return paths should treat such a
reader as must-close.
Sourcepub fn credit_granted_total(&self) -> u64
pub fn credit_granted_total(&self) -> u64
Total bytes granted to the server via CREDIT (0x15) frames
since this connection was opened. Useful for verifying that
flow-control replenishment behaves as expected — in particular,
that Cursor::cancel() doesn’t continue topping up the server’s
budget while draining frames it’s about to discard.
Sourcepub fn read_ns(&self) -> u64
pub fn read_ns(&self) -> u64
Diagnostic accumulator (nanoseconds): time spent in
transport.read_frame(). Saturates at u64::MAX (~584 years).
Reset to zero by Reader::reset_timing.
Sourcepub fn decode_ns(&self) -> u64
pub fn decode_ns(&self) -> u64
Diagnostic accumulator (nanoseconds): time spent in
decode_frame(). Saturates at u64::MAX.
Reset to zero by Reader::reset_timing.
Sourcepub fn reset_timing(&self)
pub fn reset_timing(&self)
Reset both read_ns and decode_ns accumulators to zero.
Sourcepub fn stats(&self) -> &Arc<ReaderStats> ⓘ
pub fn stats(&self) -> &Arc<ReaderStats> ⓘ
Borrow the shared diagnostic counters. The FFI clones this at
qwp_reader_from_conf time so its stat getters can read the
counters without touching the UnsafeCell<Reader> that holds
this Reader — eliminating the aliasing question of “what
happens when a stat getter synthesises a &Reader while a
laundered &mut Reader is in flight.”
Sourcepub fn server_info(&self) -> Option<&ServerInfo>
pub fn server_info(&self) -> Option<&ServerInfo>
SERVER_INFO (0x18) captured at connect time. None only while
a reconnect is in flight; the single QWP version always supplies it.
Sourcepub fn server_version(&self) -> Result<u8>
pub fn server_version(&self) -> Result<u8>
Negotiated QWP version this connection is using. Returns
SocketError when the Reader is poisoned after a failed
mid-query failover.
Sourcepub fn symbol_dict(&self) -> &SymbolDict
pub fn symbol_dict(&self) -> &SymbolDict
Connection-scoped symbol dictionary.
Sourcepub fn prepare<S: Into<String>>(&mut self, sql: S) -> ReaderQuery<'_>
pub fn prepare<S: Into<String>>(&mut self, sql: S) -> ReaderQuery<'_>
Begin building a parametrised query. The returned ReaderQuery
exclusively borrows the reader; only one in-flight cursor at a
time. Append binds in placeholder order, then call .execute().
Auto Trait Implementations§
impl !RefUnwindSafe for Reader
impl !UnwindSafe for Reader
impl Freeze for Reader
impl Send for Reader
impl Sync for Reader
impl Unpin for Reader
impl UnsafeUnpin for Reader
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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