ConnectionPool

Struct ConnectionPool 

Source
pub struct ConnectionPool(/* private fields */);
Expand description

Access to the builder’s DB connection pool and DB-access-related methods.

The handle is safe to clone and share between threads.

Implementations§

Source§

impl ConnectionPool

Source

pub fn new(conf: &Config) -> Result<Self>

Create the connection pool from the given configuration.

Source

pub fn with_tables(conf: &Config) -> Result<Self>

Create the connection pool from the given configuration and ensure the DB tables have been created if they do not already exist before returning.

Source

pub async fn acquire(&self) -> Result<ConnectionHandle, AcquireError>

Acquire a temporary database ConnectionHandle from the inner pool.

In the case that all connections are busy, waits for the first available connection.

Source

pub fn try_acquire(&self) -> Result<ConnectionHandle, TryAcquireError>

Attempt to synchronously acquire a temporary database ConnectionHandle from the inner pool.

Returns Err in the case that all database connections are busy or if the builder has been closed.

Source

pub fn close(&self) -> Result<(), ConnectionCloseErrors>

Close a connection pool, returning a ConnectionCloseErrors in the case of any errors.

Source§

impl ConnectionPool

Short-hand methods for async DB access.

Source

pub async fn acquire_then<F, T, E>( &self, f: F, ) -> Result<T, AcquireThenError<E>>
where F: 'static + Send + FnOnce(&mut ConnectionHandle) -> Result<T, E>, T: 'static + Send, E: 'static + Send,

Asynchronous access to the builder’s DB via the given function.

Requests and awaits a connection from the connection pool, then spawns a blocking task for the given function providing access to the connection handle.

Source

pub async fn create_tables(&self) -> Result<(), AcquireThenRusqliteError>

Acquire a connection and call crate::create_tables.

Source

pub async fn insert_solution_set_submission( &self, solution_set: Arc<SolutionSet>, timestamp: Duration, ) -> Result<ContentAddress, AcquireThenRusqliteError>

Acquire a connection and call crate::insert_solution_set_submission.

Source

pub async fn insert_solution_set_failure( &self, solution_set_ca: ContentAddress, failure: SolutionSetFailure<'static>, ) -> Result<(), AcquireThenRusqliteError>

Acquire a connection and call crate::insert_solution_set_failure.

Source

pub async fn get_solution_set( &self, ca: ContentAddress, ) -> Result<Option<SolutionSet>, AcquireThenQueryError>

Acquire a connection and call crate::get_solution_set.

Source

pub async fn list_solution_sets( &self, time_range: Range<Duration>, limit: i64, ) -> Result<Vec<(ContentAddress, SolutionSet, Duration)>, AcquireThenQueryError>

Acquire a connection and call crate::list_solution_sets.

Source

pub async fn list_submissions( &self, time_range: Range<Duration>, limit: i64, ) -> Result<Vec<(ContentAddress, Duration)>, AcquireThenRusqliteError>

Acquire a connection and call crate::list_submissions.

Source

pub async fn latest_solution_set_failures( &self, solution_set_ca: ContentAddress, limit: u32, ) -> Result<Vec<SolutionSetFailure<'static>>, AcquireThenRusqliteError>

Acquire a connection and call crate::latest_solution_set_failures.

Source

pub async fn list_solution_set_failures( &self, offset: u32, limit: u32, ) -> Result<Vec<SolutionSetFailure<'static>>, AcquireThenRusqliteError>

Acquire a connection and call crate::list_solution_set_failures.

Source

pub async fn delete_solution_set( &self, ca: ContentAddress, ) -> Result<(), AcquireThenRusqliteError>

Acquire a connection and call crate::delete_solution_set.

Source

pub async fn delete_solution_sets( &self, cas: impl 'static + IntoIterator<Item = ContentAddress> + Send, ) -> Result<(), AcquireThenRusqliteError>

Delete the given set of solution sets in a single transaction.

Source

pub async fn delete_oldest_solution_set_failures( &self, keep_limit: u32, ) -> Result<(), AcquireThenRusqliteError>

Acquire a connection and call crate::delete_oldest_solution_set_failures.

Trait Implementations§

Source§

impl Clone for ConnectionPool

Source§

fn clone(&self) -> ConnectionPool

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.