Skip to main content

Connection

Struct Connection 

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

A live peer connection to a transactor-hosted database.

Implementations§

Source§

impl Connection

Source

pub async fn connect(config: ConnectConfig) -> Result<Self, PeerError>

Connects, subscribes from basis 0, and waits until the handshake and its backfill have been applied locally. Candidate endpoints are tried in order; a standby transactor rejects the subscription and the next candidate is tried.

§Errors

Returns PeerError when no endpoint accepts the subscription.

Source

pub fn db_name(&self) -> &str

The connected database name.

Source

pub fn db(&self) -> Db

Returns the current local database value without blocking on the transactor.

§Panics

Panics if called before the initial handshake (impossible through Connection::connect).

Source

pub fn basis_t(&self) -> u64

Basis of the newest locally applied transaction.

Source

pub fn index_basis_t(&self) -> u64

Basis of the newest published durable index announced by the transactor.

Source

pub fn tx_reports(&self) -> Receiver<PeerReport>

Subscribes to reports applied after this call.

Source

pub fn tx_range(&self, start: u64, end: Option<u64>) -> Vec<TxRecord>

Transaction instants recorded locally for [start, end), paired with their datoms (the peer-side tx-range).

Source

pub async fn transact(&self, forms: Vec<Edn>) -> Result<TxResult, PeerError>

Submits a transaction (EDN transaction forms) and waits until it is applied locally, so a following Connection::db observes it.

Failures that are provably pre-commit — a standby or deposed transactor rejecting the request, or a connection that could not be established — are retried until ConnectConfig::failover_timeout, riding out an HA takeover. A connection that dies with the request in flight is ambiguous (the transaction may or may not have committed) and surfaces as an error, exactly like a transactor crash between durability and reply; callers decide whether to check and resubmit.

§Errors

Returns PeerError for rejected transactions or transport failure.

Source

pub async fn transact_raw( &self, tx_data: Vec<u8>, ) -> Result<TransactResponse, PeerError>

Submits already-encoded transaction data, returning the raw wire response (used by the peer server’s transact proxy).

§Errors

Returns PeerError for rejected transactions or transport failure.

Source

pub async fn sync(&self) -> Result<Db, PeerError>

Waits until the local basis reaches the transactor’s current basis.

§Errors

Returns PeerError on transport failure.

Source

pub async fn sync_to(&self, t: u64) -> Result<Db, PeerError>

Waits until the local basis reaches t, returning the database value.

§Errors

Returns PeerError::Closed if the connection task stops.

Source

pub async fn status(&self) -> Result<StatusResponse, PeerError>

Transactor-side status for the connected database.

§Errors

Returns PeerError on transport failure.

Source

pub async fn subscribe_raw( &self, from_basis_t: u64, ) -> Result<Streaming<SubscribeItem>, PeerError>

Opens an independent upstream subscription (used by the peer server to relay tx-report streams to thin clients).

§Errors

Returns PeerError on transport failure.

Trait Implementations§

Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more