pub struct PostgresClient { /* private fields */ }Expand description
A PostgreSQL client wrapping a PgPool.
Holds a connection pool that is shared across all operations created from this client. The pool is created once and reused for the lifetime of the client.
§Examples
use ironflow_ops_postgres::PostgresClient;
let client = PostgresClient::connect("postgres://localhost/mydb").await?;
let pool = client.pool();Implementations§
Source§impl PostgresClient
impl PostgresClient
Sourcepub async fn connect(url: &str) -> Result<Self, OperationError>
pub async fn connect(url: &str) -> Result<Self, OperationError>
Connect to a PostgreSQL database using the given connection URL.
§Errors
Returns OperationError::External if the connection pool cannot be
created (invalid URL, unreachable server, authentication failure).
§Examples
use ironflow_ops_postgres::PostgresClient;
let client = PostgresClient::connect("postgres://localhost/mydb").await?;Sourcepub async fn from_context(
ctx: &OperationContext,
) -> Result<Self, OperationError>
pub async fn from_context( ctx: &OperationContext, ) -> Result<Self, OperationError>
Create a client by reading postgres_url from the secret store.
§Errors
Returns OperationError::Secret if the secret store fails, or
OperationError::External if the secret is missing or the connection
cannot be established.
§Examples
use ironflow_ops_postgres::PostgresClient;
use ironflow_core::operation::{OperationContext, NoopSecretResolver};
use std::sync::Arc;
let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
let client = PostgresClient::from_context(&ctx).await?;Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresClient
impl !UnwindSafe for PostgresClient
impl Freeze for PostgresClient
impl Send for PostgresClient
impl Sync for PostgresClient
impl Unpin for PostgresClient
impl UnsafeUnpin for PostgresClient
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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