pub struct PersistentStorage { /* private fields */ }Expand description
StorageBackend implementation for PersistentStorage
Implementations§
Source§impl PersistentStorage
impl PersistentStorage
Sourcepub async fn new(node_id: OxirsNodeId, config: StorageConfig) -> Result<Self>
pub async fn new(node_id: OxirsNodeId, config: StorageConfig) -> Result<Self>
Create a new persistent storage instance
Sourcepub async fn get_current_term(&self) -> u64
pub async fn get_current_term(&self) -> u64
Get current term
Sourcepub async fn set_current_term(&self, term: u64) -> Result<()>
pub async fn set_current_term(&self, term: u64) -> Result<()>
Set current term
Sourcepub async fn get_voted_for(&self) -> Option<OxirsNodeId>
pub async fn get_voted_for(&self) -> Option<OxirsNodeId>
Get voted for
Sourcepub async fn set_voted_for(
&self,
candidate_id: Option<OxirsNodeId>,
) -> Result<()>
pub async fn set_voted_for( &self, candidate_id: Option<OxirsNodeId>, ) -> Result<()>
Set voted for
Sourcepub async fn get_log_entries(&self, start: u64, end: u64) -> Vec<LogEntry>
pub async fn get_log_entries(&self, start: u64, end: u64) -> Vec<LogEntry>
Get log entries in range
Sourcepub async fn get_log_entry(&self, index: u64) -> Option<LogEntry>
pub async fn get_log_entry(&self, index: u64) -> Option<LogEntry>
Get log entry at index
Sourcepub async fn get_last_log_index(&self) -> u64
pub async fn get_last_log_index(&self) -> u64
Get last log index
Sourcepub async fn get_last_log_term(&self) -> u64
pub async fn get_last_log_term(&self) -> u64
Get last log term
Sourcepub async fn truncate_log(&self, from_index: u64) -> Result<()>
pub async fn truncate_log(&self, from_index: u64) -> Result<()>
Truncate log from index
Sourcepub async fn get_commit_index(&self) -> u64
pub async fn get_commit_index(&self) -> u64
Get commit index
Sourcepub async fn set_commit_index(&self, index: u64) -> Result<()>
pub async fn set_commit_index(&self, index: u64) -> Result<()>
Set commit index
Sourcepub async fn get_last_applied(&self) -> u64
pub async fn get_last_applied(&self) -> u64
Get last applied index
Sourcepub async fn set_last_applied(&self, index: u64) -> Result<()>
pub async fn set_last_applied(&self, index: u64) -> Result<()>
Set last applied index
Sourcepub async fn apply_command(&self, command: &RdfCommand) -> Result<()>
pub async fn apply_command(&self, command: &RdfCommand) -> Result<()>
Apply command to state machine
Sourcepub async fn get_app_state(&self) -> RdfApp
pub async fn get_app_state(&self) -> RdfApp
Get application state
Sourcepub async fn create_snapshot(&self) -> Result<SnapshotMetadata>
pub async fn create_snapshot(&self) -> Result<SnapshotMetadata>
Create snapshot
Sourcepub async fn load_snapshot(&self) -> Result<Option<(SnapshotMetadata, RdfApp)>>
pub async fn load_snapshot(&self) -> Result<Option<(SnapshotMetadata, RdfApp)>>
Load snapshot
Sourcepub async fn compact_log(&self, until_index: u64) -> Result<()>
pub async fn compact_log(&self, until_index: u64) -> Result<()>
Compact log (remove entries before last snapshot)
Sourcepub async fn needs_compaction(&self) -> bool
pub async fn needs_compaction(&self) -> bool
Check if compaction is needed
Sourcepub async fn get_stats(&self) -> StorageStats
pub async fn get_stats(&self) -> StorageStats
Get storage statistics
Sourcepub async fn rotate_wal(&self) -> Result<()>
pub async fn rotate_wal(&self) -> Result<()>
Rotate WAL file when it gets too large
Sourcepub async fn compact_wal(&self) -> Result<()>
pub async fn compact_wal(&self) -> Result<()>
Compact WAL by removing committed entries
Sourcepub async fn verify_integrity(&self) -> Result<bool>
pub async fn verify_integrity(&self) -> Result<bool>
Verify data integrity across all files
Sourcepub async fn cleanup_old_backups(&self) -> Result<()>
pub async fn cleanup_old_backups(&self) -> Result<()>
Clean old backups
Sourcepub async fn recover_from_crash(&self) -> Result<RecoveryReport>
pub async fn recover_from_crash(&self) -> Result<RecoveryReport>
Perform crash recovery check and repair if needed
Trait Implementations§
Source§impl StorageBackend for PersistentStorage
impl StorageBackend for PersistentStorage
Source§fn create_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new shard
Source§fn delete_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete a shard
Source§fn insert_triple_to_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
triple: Triple,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert_triple_to_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
triple: Triple,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert a triple into a specific shard
Source§fn delete_triple_from_shard<'life0, 'life1, 'async_trait>(
&'life0 self,
shard_id: ShardId,
triple: &'life1 Triple,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_triple_from_shard<'life0, 'life1, 'async_trait>(
&'life0 self,
shard_id: ShardId,
triple: &'life1 Triple,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a triple from a specific shard
Source§fn query_shard<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
shard_id: ShardId,
subject: Option<&'life1 str>,
predicate: Option<&'life2 str>,
object: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn query_shard<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
shard_id: ShardId,
subject: Option<&'life1 str>,
predicate: Option<&'life2 str>,
object: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Query triples from a specific shard
Source§fn get_shard_size<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_shard_size<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get shard size in bytes
Source§fn get_shard_triple_count<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_shard_triple_count<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get shard triple count
Source§fn export_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn export_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Export shard data for migration
Source§fn import_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
triples: Vec<Triple>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn import_shard<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
triples: Vec<Triple>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Import shard data during migration
Source§fn get_shard_triples<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_shard_triples<'life0, 'async_trait>(
&'life0 self,
shard_id: ShardId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all triples from a specific shard
Auto Trait Implementations§
impl !RefUnwindSafe for PersistentStorage
impl !UnwindSafe for PersistentStorage
impl Freeze for PersistentStorage
impl Send for PersistentStorage
impl Sync for PersistentStorage
impl Unpin for PersistentStorage
impl UnsafeUnpin for PersistentStorage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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 moreimpl<T> MaybeDebug for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.