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§
Sourcefn setup_connection_pool(
settings: &Node,
database_url: Option<String>,
) -> Result<Self>where
Self: Sized,
fn setup_connection_pool(
settings: &Node,
database_url: Option<String>,
) -> Result<Self>where
Self: Sized,
Establish a pooled connection to Sqlite database.
Sourcefn conn(&self) -> Result<PooledConnection<ConnectionManager<SqliteConnection>>>
fn conn(&self) -> Result<PooledConnection<ConnectionManager<SqliteConnection>>>
Get a pooled connection for the database.
Provided Methods§
Sourcefn set_url(database_url: Option<String>) -> Option<String>
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.
Sourcefn setup(url: &str) -> Result<SqliteConnection>
fn setup(url: &str) -> Result<SqliteConnection>
Test a Sqlite connection to the database and run pending migrations.
Sourcefn health_check(
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Health, Error>
fn health_check( conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Health, Error>
Check if the database is up.
Sourcefn commit_receipt(
workflow_cid: Cid,
receipt: Receipt,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Receipt, Error>
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.
Sourcefn store_receipt(
receipt: Receipt,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Option<Receipt>, Error>
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.
Sourcefn store_receipts(
receipts: Vec<Receipt>,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<usize, Error>
fn store_receipts( receipts: Vec<Receipt>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<usize, Error>
Store receipts given a connection to the Database pool.
Sourcefn find_instruction_pointers(
pointers: &Vec<Pointer>,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Vec<Receipt>, Error>
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.
Sourcefn find_instruction_by_cid(
cid: Cid,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Receipt, Error>
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.
Sourcefn find_receipt_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>
Find a receipt for a given Cid.
Sourcefn find_receipt_pointers(
pointers: &Vec<Pointer>,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Vec<Receipt>, Error>
fn find_receipt_pointers( pointers: &Vec<Pointer>, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Vec<Receipt>, Error>
Sourcefn store_workflow(
workflow: Stored,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Stored, Error>
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.
Sourcefn set_workflow_status(
workflow_cid: Cid,
status: Status,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<(), Error>
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.
Sourcefn store_workflow_receipt(
workflow_cid: Cid,
receipt_cid: Cid,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Option<usize>, Error>
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.
Sourcefn store_workflow_receipts(
workflow_cid: Cid,
receipts: &[Cid],
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<usize, Error>
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
Sourcefn select_workflow(
cid: Cid,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<Stored, Error>
fn select_workflow( cid: Cid, conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>, ) -> Result<Stored, Error>
Select workflow given a Cid to the workflow.
Sourcefn get_workflow_info(
workflow_cid: Cid,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<(Option<String>, Info), Error>
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.
Sourcefn update_local_name(
name: &str,
conn: &mut PooledConnection<ConnectionManager<SqliteConnection>>,
) -> Result<(), Error>
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.