pub struct PqsClient { /* private fields */ }Expand description
A read client for a PQS database.
Cloning is cheap and clones share the connection, which pipelines concurrent queries — so pooling is the application’s decision rather than this crate’s, as telemetry is.
Implementations§
Source§impl PqsClient
impl PqsClient
Sourcepub async fn connect(config: &str) -> Result<Self>
pub async fn connect(config: &str) -> Result<Self>
Connect without TLS.
config is a libpq connection string —
host=… user=… password=… dbname=… — or a postgres:// URL. The
connection is driven on a spawned task; dropping every clone of the
client ends it.
§Errors
Error::Connection if the store cannot be reached, and
Error::InvalidRequest if it refuses the connection for a reason
waiting will not change — a wrong password, an unknown database.
Sourcepub async fn connect_with_timeout(
config: &str,
timeout: Duration,
) -> Result<Self>
pub async fn connect_with_timeout( config: &str, timeout: Duration, ) -> Result<Self>
connect with an explicit deadline for the attempt,
which also becomes the per-query timeout.
§Errors
As connect, plus Error::Timeout if the store did
not answer within timeout.
Sourcepub async fn connect_tls(config: &str) -> Result<Self>
Available on crate feature tls only.
pub async fn connect_tls(config: &str) -> Result<Self>
tls only.Connect over TLS, with the platform’s root certificates.
§Errors
Error::Connection if the store cannot be reached, and
Error::InvalidRequest if no root certificates can be loaded, if the
certificate cannot be verified, or if the store refuses the connection
for a reason waiting will not change.
Sourcepub async fn connect_tls_with_timeout(
config: &str,
timeout: Duration,
) -> Result<Self>
Available on crate feature tls only.
pub async fn connect_tls_with_timeout( config: &str, timeout: Duration, ) -> Result<Self>
tls only.connect_tls with an explicit deadline for the
attempt, which also becomes the per-query timeout.
TLS is required, not preferred: a store that answers the TLS request
with “no” is an error here, never a silent plaintext session.
tokio-postgres’s own default is sslmode=prefer, which is exactly that
silent fallback, and a connection string carrying sslmode=disable
would otherwise turn this method into connect.
§Errors
As connect_tls, plus Error::Timeout if the
store did not answer within timeout.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Change the deadline for every query (and reconnect) on this client and
its clones. The default is DEFAULT_TIMEOUT.
Sourcepub async fn run<T>(&self, query: &Query<T>) -> Result<Vec<Contract<T>>>where
T: ContractType + DeserializeOwned,
pub async fn run<T>(&self, query: &Query<T>) -> Result<Vec<Contract<T>>>where
T: ContractType + DeserializeOwned,
Run a query and decode every row.
§Errors
Error::Connection if the query fails, or a decoding error if a row
does not match T.
Sourcepub async fn active<T>(&self) -> Result<Vec<Contract<T>>>where
T: ContractType + DeserializeOwned,
pub async fn active<T>(&self) -> Result<Vec<Contract<T>>>where
T: ContractType + DeserializeOwned,
Sourcepub async fn lookup<T>(&self, contract_id: &str) -> Result<Option<Contract<T>>>where
T: ContractType + DeserializeOwned,
pub async fn lookup<T>(&self, contract_id: &str) -> Result<Option<Contract<T>>>where
T: ContractType + DeserializeOwned,
Sourcepub async fn exercises<T, C>(
&self,
from: Option<i64>,
to: Option<i64>,
) -> Result<Vec<Exercise<C>>>
pub async fn exercises<T, C>( &self, from: Option<i64>, to: Option<i64>, ) -> Result<Vec<Exercise<C>>>
Sourcepub async fn latest_offset(&self) -> Result<i64>
pub async fn latest_offset(&self) -> Result<i64>
The latest offset PQS has ingested.
What a caller reads to know how far behind the store is, and what to
pass to Query::active_at for a stable read.
§Errors
As run.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PqsClient
impl !UnwindSafe for PqsClient
impl Freeze for PqsClient
impl Send for PqsClient
impl Sync for PqsClient
impl Unpin for PqsClient
impl UnsafeUnpin for PqsClient
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request