Skip to main content

Reader

Struct Reader 

Source
pub struct Reader { /* private fields */ }
Expand description

Per-connection reader. Owns the WebSocket transport and the connection-scoped symbol dictionary.

Implementations§

Source§

impl Reader

Source

pub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self>

Open a new connection from a connect string.

Source

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.

Source

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:

  • RoleMismatch if every endpoint connected but none advertised a matching role (last-seen role surfaced in the message).
  • AuthError if 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).
  • SocketError if 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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn reset_timing(&self)

Reset both read_ns and decode_ns accumulators to zero.

Source

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.”

Source

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.

Source

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.

Source

pub fn symbol_dict(&self) -> &SymbolDict

Connection-scoped symbol dictionary.

Source

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().

Source

pub fn execute<S: Into<String>>(&mut self, sql: S) -> Result<Cursor<'_>>

Execute a SQL statement with no binds and return a streaming cursor. Convenience for self.prepare(sql).execute().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V