pub struct Transaction { /* private fields */ }
Expand description
A set of undoable updates and requests against a dataset.
Implementations§
Source§impl Transaction
impl Transaction
pub fn rollback_with_warning(self) -> Self
pub fn rollback_with_panic(self) -> Self
pub fn rollback_and_ignore(self) -> Self
pub fn enclose(self) -> Arc<Mutex<Self>>
Sourcepub async fn closed(&self) -> bool
pub async fn closed(&self) -> bool
Check if transaction is finished.
If the transaction has been cancelled or committed,
then this function will return true
, and any further
calls to functions on this transaction will result
in a Error::TxFinished
error.
Sourcepub async fn cancel(&mut self) -> Result<(), Error>
pub async fn cancel(&mut self) -> Result<(), Error>
Cancel a transaction.
This reverses all changes made within the transaction.
Sourcepub async fn commit(&mut self) -> Result<(), Error>
pub async fn commit(&mut self) -> Result<(), Error>
Commit a transaction.
This attempts to commit all changes made within the transaction.
Sourcepub async fn exi<K>(&mut self, key: K) -> Result<bool, Error>
pub async fn exi<K>(&mut self, key: K) -> Result<bool, Error>
Check if a key exists in the datastore.
Sourcepub async fn get<K>(&mut self, key: K) -> Result<Option<Val>, Error>
pub async fn get<K>(&mut self, key: K) -> Result<Option<Val>, Error>
Fetch a key from the datastore.
Sourcepub async fn set<K, V>(&mut self, key: K, val: V) -> Result<(), Error>
pub async fn set<K, V>(&mut self, key: K, val: V) -> Result<(), Error>
Insert or update a key in the datastore.
Sourcepub async fn get_timestamp<K>(
&mut self,
key: K,
lock: bool,
) -> Result<[u8; 10], Error>
pub async fn get_timestamp<K>( &mut self, key: K, lock: bool, ) -> Result<[u8; 10], Error>
Obtain a new change timestamp for a key which is replaced with the current timestamp when the transaction is committed. NOTE: This should be called when composing the change feed entries for this transaction, which should be done immediately before the transaction commit. That is to keep other transactions commit delay(pessimistic) or conflict(optimistic) as less as possible.
Sourcepub async fn set_versionstamped_key<K, V>(
&mut self,
ts_key: K,
prefix: K,
suffix: K,
val: V,
) -> Result<(), Error>
pub async fn set_versionstamped_key<K, V>( &mut self, ts_key: K, prefix: K, suffix: K, val: V, ) -> Result<(), Error>
Insert or update a key in the datastore.
Sourcepub async fn put<K, V>(
&mut self,
category: KeyCategory,
key: K,
val: V,
) -> Result<(), Error>
pub async fn put<K, V>( &mut self, category: KeyCategory, key: K, val: V, ) -> Result<(), Error>
Insert a key if it doesn’t exist in the datastore.
Sourcepub async fn scan<K>(
&mut self,
rng: Range<K>,
limit: u32,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn scan<K>( &mut self, rng: Range<K>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a specific range of keys from the datastore.
This function fetches the full range of key-value pairs, in a single request to the underlying datastore.
Sourcepub async fn putc<K, V>(
&mut self,
key: K,
val: V,
chk: Option<V>,
) -> Result<(), Error>
pub async fn putc<K, V>( &mut self, key: K, val: V, chk: Option<V>, ) -> Result<(), Error>
Update a key in the datastore if the current value matches a condition.
Sourcepub async fn delc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
pub async fn delc<K, V>(&mut self, key: K, chk: Option<V>) -> Result<(), Error>
Delete a key from the datastore if the current value matches a condition.
Sourcepub async fn getr<K>(
&mut self,
rng: Range<K>,
limit: u32,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn getr<K>( &mut self, rng: Range<K>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a specific range of keys from the datastore.
This function fetches key-value pairs from the underlying datastore in batches of 1000.
Sourcepub async fn delr<K>(&mut self, rng: Range<K>, limit: u32) -> Result<(), Error>
pub async fn delr<K>(&mut self, rng: Range<K>, limit: u32) -> Result<(), Error>
Delete a range of keys from the datastore.
This function fetches key-value pairs from the underlying datastore in batches of 1000.
Sourcepub async fn getp<K>(
&mut self,
key: K,
limit: u32,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn getp<K>( &mut self, key: K, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a specific prefix of keys from the datastore.
This function fetches key-value pairs from the underlying datastore in batches of 1000.
Sourcepub async fn delp<K>(&mut self, key: K, limit: u32) -> Result<(), Error>
pub async fn delp<K>(&mut self, key: K, limit: u32) -> Result<(), Error>
Delete a prefix of keys from the datastore.
This function fetches key-value pairs from the underlying datastore in batches of 1000.
Sourcepub async fn clr<K>(&mut self, key: K) -> Result<(), Error>
pub async fn clr<K>(&mut self, key: K) -> Result<(), Error>
Clear any cache entry for the specified key.
pub async fn set_nd(&mut self, id: Uuid) -> Result<(), Error>
pub async fn get_nd( &mut self, id: Uuid, ) -> Result<Option<ClusterMembership>, Error>
Sourcepub async fn clock(&mut self) -> Timestamp
pub async fn clock(&mut self) -> Timestamp
Clock retrieves the current timestamp, without guaranteeing monotonicity in all implementations.
It is used for unreliable ordering of events as well as handling of timeouts. Operations that are not guaranteed to be correct. But also allows for lexicographical ordering.
Public for tests, but not required for usage from a user perspective.
pub async fn set_hb( &mut self, timestamp: Timestamp, id: Uuid, ) -> Result<(), Error>
pub async fn del_hb( &mut self, timestamp: Timestamp, id: Uuid, ) -> Result<(), Error>
pub async fn del_nd(&mut self, node: Uuid) -> Result<(), Error>
pub async fn del_ndlq( &mut self, nd: Uuid, lq: Uuid, ns: &str, db: &str, ) -> Result<(), Error>
pub async fn scan_hb( &mut self, time_to: &Timestamp, limit: u32, ) -> Result<Vec<Hb>, Error>
Sourcepub async fn scan_nd(
&mut self,
limit: u32,
) -> Result<Vec<ClusterMembership>, Error>
pub async fn scan_nd( &mut self, limit: u32, ) -> Result<Vec<ClusterMembership>, Error>
scan_nd will scan all the cluster membership registers setting limit to 0 will result in scanning all entries
pub async fn delr_hb(&mut self, ts: Vec<Hb>, limit: u32) -> Result<(), Error>
pub async fn del_tblq( &mut self, ns: &str, db: &str, tb: &str, lv: Uuid, ) -> Result<(), Error>
pub async fn scan_ndlq<'a>( &mut self, node: &Uuid, limit: u32, ) -> Result<Vec<LqValue>, Error>
pub async fn scan_tblq<'a>( &mut self, ns: &str, db: &str, tb: &str, limit: u32, ) -> Result<Vec<LqValue>, Error>
Sourcepub async fn putc_tblq(
&mut self,
ns: &str,
db: &str,
tb: &str,
live_stm: LiveStatement,
expected: Option<LiveStatement>,
) -> Result<(), Error>
pub async fn putc_tblq( &mut self, ns: &str, db: &str, tb: &str, live_stm: LiveStatement, expected: Option<LiveStatement>, ) -> Result<(), Error>
Add live query to table
pub async fn putc_ndlq( &mut self, nd: Uuid, lq: Uuid, ns: &str, db: &str, tb: &str, chk: Option<&str>, ) -> Result<(), Error>
Sourcepub async fn all_root_users(
&mut self,
) -> Result<Arc<[DefineUserStatement]>, Error>
pub async fn all_root_users( &mut self, ) -> Result<Arc<[DefineUserStatement]>, Error>
Retrieve all ROOT users.
Sourcepub async fn all_ns(&mut self) -> Result<Arc<[DefineNamespaceStatement]>, Error>
pub async fn all_ns(&mut self) -> Result<Arc<[DefineNamespaceStatement]>, Error>
Retrieve all namespace definitions in a datastore.
Sourcepub async fn all_ns_users(
&mut self,
ns: &str,
) -> Result<Arc<[DefineUserStatement]>, Error>
pub async fn all_ns_users( &mut self, ns: &str, ) -> Result<Arc<[DefineUserStatement]>, Error>
Retrieve all namespace user definitions for a specific namespace.
Sourcepub async fn all_ns_tokens(
&mut self,
ns: &str,
) -> Result<Arc<[DefineTokenStatement]>, Error>
pub async fn all_ns_tokens( &mut self, ns: &str, ) -> Result<Arc<[DefineTokenStatement]>, Error>
Retrieve all namespace token definitions for a specific namespace.
Sourcepub async fn all_db(
&mut self,
ns: &str,
) -> Result<Arc<[DefineDatabaseStatement]>, Error>
pub async fn all_db( &mut self, ns: &str, ) -> Result<Arc<[DefineDatabaseStatement]>, Error>
Retrieve all database definitions for a specific namespace.
Sourcepub async fn all_db_users(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineUserStatement]>, Error>
pub async fn all_db_users( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineUserStatement]>, Error>
Retrieve all database user definitions for a specific database.
Sourcepub async fn all_db_tokens(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineTokenStatement]>, Error>
pub async fn all_db_tokens( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineTokenStatement]>, Error>
Retrieve all database token definitions for a specific database.
Sourcepub async fn all_db_analyzers(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineAnalyzerStatement]>, Error>
pub async fn all_db_analyzers( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineAnalyzerStatement]>, Error>
Retrieve all analyzer definitions for a specific database.
Sourcepub async fn all_db_functions(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineFunctionStatement]>, Error>
pub async fn all_db_functions( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineFunctionStatement]>, Error>
Retrieve all function definitions for a specific database.
Sourcepub async fn all_db_params(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineParamStatement]>, Error>
pub async fn all_db_params( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineParamStatement]>, Error>
Retrieve all param definitions for a specific database.
Sourcepub async fn all_sc(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineScopeStatement]>, Error>
pub async fn all_sc( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineScopeStatement]>, Error>
Retrieve all scope definitions for a specific database.
Sourcepub async fn all_sc_tokens(
&mut self,
ns: &str,
db: &str,
sc: &str,
) -> Result<Arc<[DefineTokenStatement]>, Error>
pub async fn all_sc_tokens( &mut self, ns: &str, db: &str, sc: &str, ) -> Result<Arc<[DefineTokenStatement]>, Error>
Retrieve all scope token definitions for a scope.
Sourcepub async fn all_tb(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<[DefineTableStatement]>, Error>
pub async fn all_tb( &mut self, ns: &str, db: &str, ) -> Result<Arc<[DefineTableStatement]>, Error>
Retrieve all table definitions for a specific database.
Sourcepub async fn all_tb_events(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<Arc<[DefineEventStatement]>, Error>
pub async fn all_tb_events( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineEventStatement]>, Error>
Retrieve all event definitions for a specific table.
Sourcepub async fn all_tb_fields(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<Arc<[DefineFieldStatement]>, Error>
pub async fn all_tb_fields( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineFieldStatement]>, Error>
Retrieve all field definitions for a specific table.
Sourcepub async fn all_tb_indexes(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<Arc<[DefineIndexStatement]>, Error>
pub async fn all_tb_indexes( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineIndexStatement]>, Error>
Retrieve all index definitions for a specific table.
Sourcepub async fn all_tb_views(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<Arc<[DefineTableStatement]>, Error>
pub async fn all_tb_views( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[DefineTableStatement]>, Error>
Retrieve all view definitions for a specific table.
Sourcepub async fn all_tb_lives(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<Arc<[LiveStatement]>, Error>
pub async fn all_tb_lives( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<[LiveStatement]>, Error>
Retrieve all live definitions for a specific table.
pub async fn all_lq(&mut self, nd: &Uuid) -> Result<Vec<LqValue>, Error>
Sourcepub async fn get_root_user(
&mut self,
user: &str,
) -> Result<DefineUserStatement, Error>
pub async fn get_root_user( &mut self, user: &str, ) -> Result<DefineUserStatement, Error>
Retrieve a specific user definition from ROOT.
Sourcepub async fn get_ns(
&mut self,
ns: &str,
) -> Result<DefineNamespaceStatement, Error>
pub async fn get_ns( &mut self, ns: &str, ) -> Result<DefineNamespaceStatement, Error>
Retrieve a specific namespace definition.
Sourcepub async fn get_ns_user(
&mut self,
ns: &str,
user: &str,
) -> Result<DefineUserStatement, Error>
pub async fn get_ns_user( &mut self, ns: &str, user: &str, ) -> Result<DefineUserStatement, Error>
Retrieve a specific user definition from a namespace.
Sourcepub async fn get_ns_token(
&mut self,
ns: &str,
nt: &str,
) -> Result<DefineTokenStatement, Error>
pub async fn get_ns_token( &mut self, ns: &str, nt: &str, ) -> Result<DefineTokenStatement, Error>
Retrieve a specific namespace token definition.
Sourcepub async fn get_db(
&mut self,
ns: &str,
db: &str,
) -> Result<DefineDatabaseStatement, Error>
pub async fn get_db( &mut self, ns: &str, db: &str, ) -> Result<DefineDatabaseStatement, Error>
Retrieve a specific database definition.
Sourcepub async fn get_db_user(
&mut self,
ns: &str,
db: &str,
user: &str,
) -> Result<DefineUserStatement, Error>
pub async fn get_db_user( &mut self, ns: &str, db: &str, user: &str, ) -> Result<DefineUserStatement, Error>
Retrieve a specific user definition from a database.
Sourcepub async fn get_db_token(
&mut self,
ns: &str,
db: &str,
dt: &str,
) -> Result<DefineTokenStatement, Error>
pub async fn get_db_token( &mut self, ns: &str, db: &str, dt: &str, ) -> Result<DefineTokenStatement, Error>
Retrieve a specific database token definition.
Sourcepub async fn get_db_analyzer(
&mut self,
ns: &str,
db: &str,
az: &str,
) -> Result<DefineAnalyzerStatement, Error>
pub async fn get_db_analyzer( &mut self, ns: &str, db: &str, az: &str, ) -> Result<DefineAnalyzerStatement, Error>
Retrieve a specific analyzer definition.
Sourcepub async fn get_sc(
&mut self,
ns: &str,
db: &str,
sc: &str,
) -> Result<DefineScopeStatement, Error>
pub async fn get_sc( &mut self, ns: &str, db: &str, sc: &str, ) -> Result<DefineScopeStatement, Error>
Retrieve a specific scope definition.
Sourcepub async fn get_sc_token(
&mut self,
ns: &str,
db: &str,
sc: &str,
st: &str,
) -> Result<DefineTokenStatement, Error>
pub async fn get_sc_token( &mut self, ns: &str, db: &str, sc: &str, st: &str, ) -> Result<DefineTokenStatement, Error>
Retrieve a specific scope token definition.
Sourcepub async fn get_lq(
&mut self,
nd: Uuid,
ns: &str,
db: &str,
lq: Uuid,
) -> Result<Strand, Error>
pub async fn get_lq( &mut self, nd: Uuid, ns: &str, db: &str, lq: Uuid, ) -> Result<Strand, Error>
Return the table stored at the lq address
Sourcepub async fn get_tb(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<DefineTableStatement, Error>
pub async fn get_tb( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<DefineTableStatement, Error>
Retrieve a specific table definition.
Sourcepub async fn get_tb_live(
&mut self,
ns: &str,
db: &str,
tb: &str,
lv: &Uuid,
) -> Result<LiveStatement, Error>
pub async fn get_tb_live( &mut self, ns: &str, db: &str, tb: &str, lv: &Uuid, ) -> Result<LiveStatement, Error>
Retrieve a live query for a table.
Sourcepub async fn add_ns(
&mut self,
ns: &str,
strict: bool,
) -> Result<DefineNamespaceStatement, Error>
pub async fn add_ns( &mut self, ns: &str, strict: bool, ) -> Result<DefineNamespaceStatement, Error>
Add a namespace with a default configuration, only if we are in dynamic mode.
Sourcepub async fn add_db(
&mut self,
ns: &str,
db: &str,
strict: bool,
) -> Result<DefineDatabaseStatement, Error>
pub async fn add_db( &mut self, ns: &str, db: &str, strict: bool, ) -> Result<DefineDatabaseStatement, Error>
Add a database with a default configuration, only if we are in dynamic mode.
Sourcepub async fn add_sc(
&mut self,
ns: &str,
db: &str,
sc: &str,
strict: bool,
) -> Result<DefineScopeStatement, Error>
pub async fn add_sc( &mut self, ns: &str, db: &str, sc: &str, strict: bool, ) -> Result<DefineScopeStatement, Error>
Add a scope with a default configuration, only if we are in dynamic mode.
Sourcepub async fn add_tb(
&mut self,
ns: &str,
db: &str,
tb: &str,
strict: bool,
) -> Result<DefineTableStatement, Error>
pub async fn add_tb( &mut self, ns: &str, db: &str, tb: &str, strict: bool, ) -> Result<DefineTableStatement, Error>
Add a table with a default configuration, only if we are in dynamic mode.
Sourcepub async fn get_and_cache_ns(
&mut self,
ns: &str,
) -> Result<Arc<DefineNamespaceStatement>, Error>
pub async fn get_and_cache_ns( &mut self, ns: &str, ) -> Result<Arc<DefineNamespaceStatement>, Error>
Retrieve and cache a specific namespace definition.
Sourcepub async fn get_and_cache_db(
&mut self,
ns: &str,
db: &str,
) -> Result<Arc<DefineDatabaseStatement>, Error>
pub async fn get_and_cache_db( &mut self, ns: &str, db: &str, ) -> Result<Arc<DefineDatabaseStatement>, Error>
Retrieve and cache a specific database definition.
Sourcepub async fn get_and_cache_tb(
&mut self,
ns: &str,
db: &str,
tb: &str,
) -> Result<Arc<DefineTableStatement>, Error>
pub async fn get_and_cache_tb( &mut self, ns: &str, db: &str, tb: &str, ) -> Result<Arc<DefineTableStatement>, Error>
Retrieve and cache a specific table definition.
Sourcepub async fn get_and_cache_db_function(
&mut self,
ns: &str,
db: &str,
fc: &str,
) -> Result<Arc<DefineFunctionStatement>, Error>
pub async fn get_and_cache_db_function( &mut self, ns: &str, db: &str, fc: &str, ) -> Result<Arc<DefineFunctionStatement>, Error>
Retrieve a specific function definition.
Sourcepub async fn get_and_cache_db_param(
&mut self,
ns: &str,
db: &str,
pa: &str,
) -> Result<Arc<DefineParamStatement>, Error>
pub async fn get_and_cache_db_param( &mut self, ns: &str, db: &str, pa: &str, ) -> Result<Arc<DefineParamStatement>, Error>
Retrieve a specific param definition.
Sourcepub async fn get_and_cache_tb_index(
&mut self,
ns: &str,
db: &str,
tb: &str,
ix: &str,
) -> Result<Arc<DefineIndexStatement>, Error>
pub async fn get_and_cache_tb_index( &mut self, ns: &str, db: &str, tb: &str, ix: &str, ) -> Result<Arc<DefineIndexStatement>, Error>
Retrieve a specific table index definition.
Sourcepub async fn add_and_cache_ns(
&mut self,
ns: &str,
strict: bool,
) -> Result<Arc<DefineNamespaceStatement>, Error>
pub async fn add_and_cache_ns( &mut self, ns: &str, strict: bool, ) -> Result<Arc<DefineNamespaceStatement>, Error>
Add a namespace with a default configuration, only if we are in dynamic mode.
Sourcepub async fn add_and_cache_db(
&mut self,
ns: &str,
db: &str,
strict: bool,
) -> Result<Arc<DefineDatabaseStatement>, Error>
pub async fn add_and_cache_db( &mut self, ns: &str, db: &str, strict: bool, ) -> Result<Arc<DefineDatabaseStatement>, Error>
Add a database with a default configuration, only if we are in dynamic mode.
Sourcepub async fn add_and_cache_tb(
&mut self,
ns: &str,
db: &str,
tb: &str,
strict: bool,
) -> Result<Arc<DefineTableStatement>, Error>
pub async fn add_and_cache_tb( &mut self, ns: &str, db: &str, tb: &str, strict: bool, ) -> Result<Arc<DefineTableStatement>, Error>
Add a table with a default configuration, only if we are in dynamic mode.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Transaction
impl !RefUnwindSafe for Transaction
impl !Send for Transaction
impl !Sync for Transaction
impl Unpin for Transaction
impl !UnwindSafe for Transaction
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
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>
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>
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