Struct mz_stash::postgres::Postgres

source ·
pub struct Postgres {
    txn_mode: TransactionMode,
    url: String,
    schema: Option<String>,
    tls: MakeTlsConnector,
    client: Option<Client>,
    statements: Option<PreparedStatements>,
    epoch: Option<NonZeroI64>,
    nonce: [u8; 16],
    sinces_tx: UnboundedSender<(Id, Antichain<Timestamp>)>,
    metrics: Arc<Metrics>,
}
Expand description

A Stash whose data is stored in a Postgres database. The format of the tables are not specified and should not be relied upon. The only promise is stability. Any changes to the table schemas will be accompanied by a clear migration path.

Fields§

§txn_mode: TransactionMode§url: String§schema: Option<String>§tls: MakeTlsConnector§client: Option<Client>§statements: Option<PreparedStatements>§epoch: Option<NonZeroI64>§nonce: [u8; 16]§sinces_tx: UnboundedSender<(Id, Antichain<Timestamp>)>§metrics: Arc<Metrics>

Implementations§

Drops all tables associated with the stash if they exist.

Verifies stash invariants. Should only be called by tests.

Sets client to a new connection to the Postgres server.

Construct a fenced transaction, which will cause this Stash to fail if another connection is opened to it. f may be called multiple times in a backoff-retry loop if the Postgres server is unavailable, so it should only call functions on its Transaction argument.

Examples
async fn x(&mut self) -> Result<(), StashError> {
    self.transact(move |stmts, tx| {
        Box::pin(async move {
            // Use tx.
        })
    })
    .await

seals has tuples of (collection id, new upper, Option<current upper>). The current upper can be Some if it is already known.

upper can be Some if the collection’s upper is already known.

compactions has tuples of (collection id, new since, Option<current upper>). The current upper can be Some if it is already known.

Returns sinces for the requested collections.

Trait Implementations§

Same as append, but does not consolidate batches.
Atomically adds entries, seals, compacts, and consolidates multiple collections. Read more
Formats the value using the given formatter. Read more

Reports the current since frontier.

Reports the current upper frontier.

Loads or creates the named collection. Read more
Returns the names of the collections in the stash.
Iterates over all entries in the stash. Read more
Iterates over entries in the stash for the given key. Read more
Atomically adds multiple entries to the arrangement. Read more
Atomically advances the upper frontier to the specified value. Read more
Performs multiple seals at once, potentially in a more performant way than performing the individual seals one by one. Read more
Atomically advances the since frontier to the specified value. Read more
Performs multiple compactions at once, potentially in a more performant way than performing the individual compactions one by one. Read more
Atomically consolidates entries less than the since frontier. Read more
Performs multiple consolidations at once, potentially in a more performant way than performing the individual consolidations one by one. Read more
Returns Ok if this stash instance was the leader at some point from the invocation of this method to the return of this method. Otherwise, returns Err.
Reports whether the stash is in readonly mode. Read more
Returns the stash’s epoch number. If Some, it is a positive number that increases with each start of a stash.
Returns the most recent timestamp at which sealed entries can be read.
Returns the current value of sealed entries. Read more
Returns the current k,v pairs of sealed entries, erroring if there is more than one entry for a given key or the multiplicity is not 1 for each key. Read more
Returns the current sealed value for the given key, erroring if there is more than one entry for the key or its multiplicity is not 1. Read more
Atomically adds a single entry to the arrangement. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Wrap the input message T in a tonic::Request
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more