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_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>
pub fn file_span(&self, queue: LogQueue) -> (u64, u64)
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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