pub struct PgStore { /* private fields */ }Expand description
The store on PostgreSQL, with a connection pool. Send + Sync: share one per process
(behind an Arc); each call checks a connection out for its duration.
Every put_* is one transaction. Store methods return errors: a malformed argument
is Error::Invalid (no query is made), a database failure Error::Database. The
Resolver methods answer both with None; a database failure is logged with
tracing (target datumesh_store, level error).
Implementations§
Source§impl PgStore
impl PgStore
Sourcepub fn connect(url: &str) -> Result<PgStore>
pub fn connect(url: &str) -> Result<PgStore>
Connects to a postgres:// URL or key=value connection string, without TLS, with
the default PoolOptions. One connection is opened at once, so a wrong URL fails
here. For TLS, use with_connector.
Sourcepub fn with_connector<F>(connect: F, options: PoolOptions) -> Result<PgStore>
pub fn with_connector<F>(connect: F, options: PoolOptions) -> Result<PgStore>
A store whose pool opens connections with connect (any TLS setup, any
configuration). One connection is opened at once, so a failing connector fails here.
Sourcepub fn check_statements(&self) -> Result<usize>
pub fn check_statements(&self) -> Result<usize>
Prepares every SQL statement the store uses against the live schema, on a fresh connection’s behalf (no cached statement is reused), and returns how many there are. Fails with the first statement the schema cannot serve.
Trait Implementations§
Source§impl Resolver for PgStore
impl Resolver for PgStore
Source§fn evaluate(&self, cell: &Cell, asof: &str) -> Option<Scalar>
fn evaluate(&self, cell: &Cell, asof: &str) -> Option<Scalar>
Some only for a stored function (descriptor code.lang is stored, and the store
has the descriptor): the value of the receipt of the cell’s latest version with
tx <= asof. None for every other function, and when no version is that old.
Source§impl Store for PgStore
impl Store for PgStore
Source§fn put_descriptor(&self, bytes: &[u8]) -> Result<String>
fn put_descriptor(&self, bytes: &[u8]) -> Result<String>
Source§fn put_receipt(&self, bytes: &[u8]) -> Result<String>
fn put_receipt(&self, bytes: &[u8]) -> Result<String>
put_namespace, in canonical form,
with an edge to each of its inputs; returns its hash. A receipt that does not verify
is refused with verify’s code (no key document for the host: E_KEY_UNAVAILABLE).
Idempotent: bytes whose canonical form is the stored copy return its hash without
checking the signature again (it verified when stored), even if the key has since
been revoked. Other bytes with a stored hash are verified first, then refused as
Error::Conflict.Source§fn put_blob(&self, bytes: &[u8]) -> Result<String>
fn put_blob(&self, bytes: &[u8]) -> Result<String>
Source§fn put_version(&self, cell_id: &str, tx: &str, receipt_hash: &str) -> Result<()>
fn put_version(&self, cell_id: &str, tx: &str, receipt_hash: &str) -> Result<()>
tx on, cell_id has the value of receipt receipt_hash,
which must be stored, of that cell and at that tx. tx must be later than the cell’s
latest version (Error::NotLater).Source§fn version_asof(&self, cell_id: &str, asof: &str) -> Result<Option<Version>>
fn version_asof(&self, cell_id: &str, asof: &str) -> Result<Option<Version>>
tx <= asof.Source§fn versions(&self, cell_id: &str, from: &str, to: &str) -> Result<Vec<Version>>
fn versions(&self, cell_id: &str, from: &str, to: &str) -> Result<Vec<Version>>
from <= tx <= to, in tx order.Source§fn dependents(&self, receipt_hash: &str) -> Result<Vec<String>>
fn dependents(&self, receipt_hash: &str) -> Result<Vec<String>>
receipt_hash among their inputs, by hash.Source§fn inputs(&self, receipt_hash: &str) -> Result<Vec<String>>
fn inputs(&self, receipt_hash: &str) -> Result<Vec<String>>
Source§fn put_namespace(
&self,
host: &str,
keydoc_bytes: &[u8],
validated_at: &str,
) -> Result<()>
fn put_namespace( &self, host: &str, keydoc_bytes: &[u8], validated_at: &str, ) -> Result<()>
validated_at. Re-validation replaces the document; a
validated_at earlier than the recorded one is Error::NotLater. Receipts already
stored are not re-checked: they verified when they were stored (and putting one again
stays idempotent).