Skip to main content

PgExecutor

Struct PgExecutor 

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

The PostgreSQL executor as a fireweed_dsl::Executor. Each call takes an idle connection, or opens one, and gives it back when the call finishes. A call that is dropped part way drops its connection instead, so no connection with an open transaction is reused. Connections are opened on demand; at most max_idle are kept between calls.

Implementations§

Source§

impl PgExecutor

Source

pub fn new(config: Config) -> Self

Connects without TLS using config, spawning each connection’s task on the current Tokio runtime.

Source

pub fn with_connector<F, Fut>(connect: F) -> Self
where F: Fn() -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Client, Error>> + Send + 'static,

Opens connections with connect, for TLS or other settings. It must also drive (spawn) each connection’s task.

Source

pub fn max_idle(self, n: usize) -> Self

How many idle connections to keep between calls (default 16).

Trait Implementations§

Source§

impl Executor for PgExecutor

Source§

fn apply_schema<'a>( &'a self, tenant: &'a str, space: &'a str, schema: &'a Schema, expected: Option<i64>, ) -> BoxFuture<'a, Result<Applied>>

Creates a space, or changes its schema. expected is the version the caller expects to replace: None for a new space.
Source§

fn get_schema<'a>( &'a self, tenant: &'a str, space: &'a str, ) -> BoxFuture<'a, Result<Option<Schema>>>

The stored schema of a space, if it exists.
Source§

fn execute<'a>( &'a self, tenant: &'a str, space: &'a str, program: &'a Program, ) -> BoxFuture<'a, Result<Response>>

Runs a program as one transaction.
Source§

fn execute_batch<'a>( &'a self, tenant: &'a str, space: &'a str, programs: &'a [Program], ) -> BoxFuture<'a, Result<Vec<Result<Response>>>>

Runs independent programs in one space with one commit; each gets its own result, in order.
Source§

fn sweep<'a>( &'a self, tenant: &'a str, space: &'a str, batch: u32, ) -> BoxFuture<'a, Result<Swept>>

Writes back expired leases and deletes what retention expired, at most batch rows per object.

Auto Trait Implementations§

§

impl !Freeze for PgExecutor

§

impl !RefUnwindSafe for PgExecutor

§

impl !UnwindSafe for PgExecutor

§

impl Forget for PgExecutor

§

impl Move for PgExecutor

§

impl Send for PgExecutor
where BoxRaw<dyn Fn() -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send>> + Sync + Send>: Send, Mutex<Vec<Client>>: Send,

§

impl Sync for PgExecutor
where BoxRaw<dyn Fn() -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send>> + Sync + Send>: Sync, Mutex<Vec<Client>>: Sync,

§

impl Unpin for PgExecutor
where Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send>> + Sync + Send>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, *const u8 is !null: Unpin, Arc<InnerClient>: Unpin,

§

impl UnsafeUnpin for PgExecutor
where *const dyn Fn() -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send>> + Sync + Send is !null: UnsafeUnpin, PhantomData<dyn Fn() -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send>> + Sync + Send>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Client>: UnsafeUnpin,

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, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.