pub enum QueryIsolation {
ReadUncommitted,
ReadCommitted {
wait_for: Vec<ConsensusId>,
},
Snapshot {
prestate_hash: Hash32,
},
ReadLatest {
scope: ResourceScope,
},
}Expand description
Query isolation levels for consistency requirements.
Aura’s journal is eventually consistent via CRDT merge. These isolation levels let queries specify their consistency requirements:
ReadUncommitted: See latest CRDT state (fastest, may see uncommitted facts)ReadCommitted: Only see facts confirmed by consensusSnapshot: Query against a specific historical prestateReadLatest: Wait for all pending consensus in scope to complete
§Example
// Fast query - may see uncommitted facts
let result = effects.query_with_isolation(
&ChannelsQuery::default(),
QueryIsolation::ReadUncommitted,
).await?;
// Strong consistency - wait for specific consensus
let result = effects.query_with_isolation(
&ChannelsQuery::default(),
QueryIsolation::ReadCommitted { wait_for: vec![consensus_id] },
).await?;Variants§
ReadUncommitted
See all facts including uncommitted (CRDT state).
Fastest option - queries execute immediately against the current CRDT state without waiting for consensus confirmation.
ReadCommitted
Only see facts with consensus commit.
Waits for specified consensus instances to complete before executing the query. Use this when you need to see the results of specific operations that required consensus.
Fields
wait_for: Vec<ConsensusId>Consensus instances to wait for before executing query
Snapshot
Snapshot at specific prestate (time-travel query).
Queries against a historical state identified by its prestate hash. Useful for auditing or debugging. The prestate must still be available (not garbage collected).
ReadLatest
Wait for all pending consensus in scope to complete.
More expensive than ReadCommitted - waits for all pending consensus
operations that affect the specified resource scope. Use sparingly.
Note: This is NOT linearizable - just ensures all pending commits are visible at query time.
Fields
scope: ResourceScopeResource scope to wait for
Implementations§
Source§impl QueryIsolation
impl QueryIsolation
Sourcepub fn read_committed(consensus_id: ConsensusId) -> Self
pub fn read_committed(consensus_id: ConsensusId) -> Self
Create a ReadCommitted isolation waiting for a single consensus
Sourcepub fn snapshot(prestate_hash: Hash32) -> Self
pub fn snapshot(prestate_hash: Hash32) -> Self
Create a Snapshot isolation for a specific prestate
Sourcepub fn read_latest(scope: ResourceScope) -> Self
pub fn read_latest(scope: ResourceScope) -> Self
Create a ReadLatest isolation for a resource scope
Sourcepub fn requires_wait(&self) -> bool
pub fn requires_wait(&self) -> bool
Check if this isolation level requires waiting
Trait Implementations§
Source§impl Clone for QueryIsolation
impl Clone for QueryIsolation
Source§fn clone(&self) -> QueryIsolation
fn clone(&self) -> QueryIsolation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QueryIsolation
impl Debug for QueryIsolation
Source§impl Default for QueryIsolation
impl Default for QueryIsolation
Source§fn default() -> QueryIsolation
fn default() -> QueryIsolation
Source§impl<'de> Deserialize<'de> for QueryIsolation
impl<'de> Deserialize<'de> for QueryIsolation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for QueryIsolation
impl PartialEq for QueryIsolation
Source§impl Serialize for QueryIsolation
impl Serialize for QueryIsolation
impl Eq for QueryIsolation
impl StructuralPartialEq for QueryIsolation
Auto Trait Implementations§
impl Freeze for QueryIsolation
impl RefUnwindSafe for QueryIsolation
impl Send for QueryIsolation
impl Sync for QueryIsolation
impl Unpin for QueryIsolation
impl UnsafeUnpin for QueryIsolation
impl UnwindSafe for QueryIsolation
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.