Database

Trait Database 

Source
pub trait Database:
    Send
    + Sync
    + Clone {
Show 20 methods // Required methods fn setup_connection_pool( settings: &Node, database_url: Option<String>, ) -> Result<Self> where Self: Sized; fn conn( &self, ) -> Result<PooledConnection<ConnectionManager<SqliteConnection>>>; // Provided methods fn set_url(database_url: Option<String>) -> Option<String> { ... } fn url() -> Result<String> { ... } fn setup(url: &str) -> Result<SqliteConnection> { ... } fn health_check( conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Health, Error> { ... } fn commit_receipt( workflow_cid: Cid, receipt: Receipt, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Receipt, Error> { ... } fn store_receipt( receipt: Receipt, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Option<Receipt>, Error> { ... } fn store_receipts( receipts: Vec<Receipt>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<usize, Error> { ... } fn find_instruction_pointers( pointers: &Vec<Pointer>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Vec<Receipt>, Error> { ... } fn find_instruction_by_cid( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Receipt, Error> { ... } fn find_receipt_by_cid( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Receipt, Error> { ... } fn find_receipt_pointers( pointers: &Vec<Pointer>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Vec<Receipt>, Error> { ... } fn store_workflow( workflow: Stored, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Stored, Error> { ... } fn set_workflow_status( workflow_cid: Cid, status: Status, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<(), Error> { ... } fn store_workflow_receipt( workflow_cid: Cid, receipt_cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Option<usize>, Error> { ... } fn store_workflow_receipts( workflow_cid: Cid, receipts: &[Cid], conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<usize, Error> { ... } fn select_workflow( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Stored, Error> { ... } fn get_workflow_info( workflow_cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<(Option<String>, Info), Error> { ... } fn update_local_name( name: &str, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<(), Error> { ... }
}
Expand description

Database trait for working with different Sqlite connection pool and connection configurations.

Required Methods§

Source

fn setup_connection_pool( settings: &Node, database_url: Option<String>, ) -> Result<Self>
where Self: Sized,

Establish a pooled connection to Sqlite database.

Source

fn conn(&self) -> Result<PooledConnection<ConnectionManager<SqliteConnection>>>

Get a pooled connection for the database.

Provided Methods§

Source

fn set_url(database_url: Option<String>) -> Option<String>

Set database url.

Contains a minimal side-effect to set the env if not already set.

Source

fn url() -> Result<String>

Get database url.

Source

fn setup(url: &str) -> Result<SqliteConnection>

Test a Sqlite connection to the database and run pending migrations.

Source

fn health_check( conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Health, Error>

Check if the database is up.

Source

fn commit_receipt( workflow_cid: Cid, receipt: Receipt, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Receipt, Error>

Commit a receipt to the database, updating two tables within a transaction.

Source

fn store_receipt( receipt: Receipt, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Option<Receipt>, Error>

Store receipt given a connection to the database pool.

On conflicts, do nothing.

Source

fn store_receipts( receipts: Vec<Receipt>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<usize, Error>

Store receipts given a connection to the Database pool.

Source

fn find_instruction_pointers( pointers: &Vec<Pointer>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Vec<Receipt>, Error>

Find receipts given a set of Instruction Pointers, which is indexed.

Source

fn find_instruction_by_cid( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Receipt, Error>

Find receipt for a given Instruction Cid, which is indexed.

Source

fn find_receipt_by_cid( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Receipt, Error>

Find a receipt for a given Cid.

Source

fn find_receipt_pointers( pointers: &Vec<Pointer>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Vec<Receipt>, Error>

Find receipts given a batch of Receipt Pointers.

Source

fn store_workflow( workflow: Stored, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Stored, Error>

Store localized workflow cid and information, e.g. number of tasks.

On conflicts, do nothing. Otherwise, return the stored workflow.

Source

fn set_workflow_status( workflow_cid: Cid, status: Status, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<(), Error>

Update workflow status given a Cid to the workflow.

Source

fn store_workflow_receipt( workflow_cid: Cid, receipt_cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Option<usize>, Error>

Store workflow Cid and Receipt Cid in the database for inner join.

Source

fn store_workflow_receipts( workflow_cid: Cid, receipts: &[Cid], conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<usize, Error>

Store series of receipts for a workflow Cid in the schema::workflows_receipts table.

NOTE: We cannot do batch inserts with on_conflict, so we add each one 1-by-1: https://github.com/diesel-rs/diesel/issues/3114

Source

fn select_workflow( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Stored, Error>

Select workflow given a Cid to the workflow.

Source

fn get_workflow_info( workflow_cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<(Option<String>, Info), Error>

Return workflow information with number of receipts emitted.

Source

fn update_local_name( name: &str, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<(), Error>

Update the local (view) name of a workflow.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§