Struct raft_engine::Engine
source · [−]pub struct Engine<F = DefaultFileSystem, P = FilePipeLog<F>>where
F: FileSystem,
P: PipeLog,{ /* private fields */ }Implementations
sourceimpl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>
impl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>
pub fn open(
cfg: Config
) -> Result<Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>>
pub fn open_with_listeners(
cfg: Config,
listeners: Vec<Arc<dyn EventListener>>
) -> Result<Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>>
sourceimpl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
impl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
pub fn open_with_file_system(
cfg: Config,
file_system: Arc<F>
) -> Result<Engine<F, FilePipeLog<F>>>
pub fn open_with(
cfg: Config,
file_system: Arc<F>,
listeners: Vec<Arc<dyn EventListener>>
) -> Result<Engine<F, FilePipeLog<F>>>
sourceimpl<F, P> Engine<F, P>where
F: FileSystem,
P: PipeLog,
impl<F, P> Engine<F, P>where
F: FileSystem,
P: PipeLog,
sourcepub fn write(&self, log_batch: &mut LogBatch, sync: bool) -> Result<usize>
pub fn write(&self, log_batch: &mut LogBatch, sync: bool) -> Result<usize>
Writes the content of log_batch into the engine and returns written
bytes. If sync is true, the write will be followed by a call to
fdatasync on the log file.
pub fn get_message<S: Message>(
&self,
region_id: u64,
key: &[u8]
) -> Result<Option<S>>
pub fn get(&self, region_id: u64, key: &[u8]) -> Option<Vec<u8>>
sourcepub fn scan_messages<S, C>(
&self,
region_id: u64,
start_key: Option<&[u8]>,
end_key: Option<&[u8]>,
reverse: bool,
callback: C
) -> Result<()>where
S: Message,
C: FnMut(&[u8], S) -> bool,
pub fn scan_messages<S, C>(
&self,
region_id: u64,
start_key: Option<&[u8]>,
end_key: Option<&[u8]>,
reverse: bool,
callback: C
) -> Result<()>where
S: Message,
C: FnMut(&[u8], S) -> bool,
Iterates over [start_key, end_key) range of Raft Group key-values and yields messages of the required type. Unparsable items are skipped.
sourcepub fn scan_raw_messages<C>(
&self,
region_id: u64,
start_key: Option<&[u8]>,
end_key: Option<&[u8]>,
reverse: bool,
callback: C
) -> Result<()>where
C: FnMut(&[u8], &[u8]) -> bool,
pub fn scan_raw_messages<C>(
&self,
region_id: u64,
start_key: Option<&[u8]>,
end_key: Option<&[u8]>,
reverse: bool,
callback: C
) -> Result<()>where
C: FnMut(&[u8], &[u8]) -> bool,
Iterates over [start_key, end_key) range of Raft Group key-values and yields all key value pairs as bytes.
pub fn get_entry<M: MessageExt>(
&self,
region_id: u64,
log_idx: u64
) -> Result<Option<M::Entry>>
sourcepub fn purge_expired_files(&self) -> Result<Vec<u64>>
pub fn purge_expired_files(&self) -> Result<Vec<u64>>
Purges expired logs files and returns a set of Raft group ids that need to be compacted.
sourcepub fn fetch_entries_to<M: MessageExt>(
&self,
region_id: u64,
begin: u64,
end: u64,
max_size: Option<usize>,
vec: &mut Vec<M::Entry>
) -> Result<usize>
pub fn fetch_entries_to<M: MessageExt>(
&self,
region_id: u64,
begin: u64,
end: u64,
max_size: Option<usize>,
vec: &mut Vec<M::Entry>
) -> Result<usize>
Returns count of fetched entries.
pub fn first_index(&self, region_id: u64) -> Option<u64>
pub fn last_index(&self, region_id: u64) -> Option<u64>
sourcepub fn compact_to(&self, region_id: u64, index: u64) -> u64
pub fn compact_to(&self, region_id: u64, index: u64) -> u64
Deletes log entries before index in the specified Raft group. Returns
the number of deleted entries.
pub fn raft_groups(&self) -> Vec<u64>
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the engine contains no Raft Group. Empty Raft Group
that isn’t cleaned is counted as well.
sourcepub fn file_span(&self, queue: LogQueue) -> (u64, u64)
pub fn file_span(&self, queue: LogQueue) -> (u64, u64)
Returns the sequence number range of active log files in the specific log queue. For testing only.
pub fn get_used_size(&self) -> usize
sourceimpl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>
impl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>
pub fn consistency_check(path: &Path) -> Result<Vec<(u64, u64)>>
pub fn dump(path: &Path) -> Result<LogItemReader<DefaultFileSystem>>
sourceimpl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
impl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
sourcepub fn consistency_check_with_file_system(
path: &Path,
file_system: Arc<F>
) -> Result<Vec<(u64, u64)>>
pub fn consistency_check_with_file_system(
path: &Path,
file_system: Arc<F>
) -> Result<Vec<(u64, u64)>>
Returns a list of corrupted Raft groups, including their ids and last valid log index. Head or tail corruption cannot be detected.
sourcepub fn dump_with_file_system(
path: &Path,
file_system: Arc<F>
) -> Result<LogItemReader<F>>
pub fn dump_with_file_system(
path: &Path,
file_system: Arc<F>
) -> Result<LogItemReader<F>>
Dumps all operations.
Trait Implementations
Auto Trait Implementations
impl<F = DefaultFileSystem, P = DualPipes<F>> !RefUnwindSafe for Engine<F, P>
impl<F, P> Send for Engine<F, P>where
P: Send + Sync,
impl<F, P> Sync for Engine<F, P>where
P: Send + Sync,
impl<F, P> Unpin for Engine<F, P>where
F: Unpin,
impl<F = DefaultFileSystem, P = DualPipes<F>> !UnwindSafe for Engine<F, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more