pub struct WriteBehindQueue { /* private fields */ }Expand description
Write-behind 持久化队列
WAL 持久化先于返回成功(宕机不丢数据), 内存待刷盘队列 + 单调递增序列号。
Implementations§
Source§impl WriteBehindQueue
impl WriteBehindQueue
Sourcepub fn new(config: WriteBehindConfig) -> Result<Self>
pub fn new(config: WriteBehindConfig) -> Result<Self>
创建 Write-behind 队列
Sourcepub fn enqueue(&self, op: WriteOp) -> Result<()>
pub fn enqueue(&self, op: WriteOp) -> Result<()>
入队写操作(WAL 持久化 + 入内存队列,立即返回)
WAL 持久化先于返回成功,保证宕机不丢数据。
Sourcepub fn drain_batch(&self) -> Vec<WriteOp>
pub fn drain_batch(&self) -> Vec<WriteOp>
批量取出待刷盘操作
Sourcepub fn truncate_wal(&self) -> Result<()>
pub fn truncate_wal(&self) -> Result<()>
标记 WAL 已刷盘(截断)
Sourcepub fn replay(&self) -> Result<Vec<WriteOp>>
pub fn replay(&self) -> Result<Vec<WriteOp>>
宕机重启回放 WAL
读取 WAL 文件,CRC 校验 + 解密,按 sequence 顺序回放未刷盘 WriteOp。
Sourcepub fn config(&self) -> &WriteBehindConfig
pub fn config(&self) -> &WriteBehindConfig
获取配置
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
获取待刷盘数量
Auto Trait Implementations§
impl !Freeze for WriteBehindQueue
impl !RefUnwindSafe for WriteBehindQueue
impl Send for WriteBehindQueue
impl Sync for WriteBehindQueue
impl Unpin for WriteBehindQueue
impl UnsafeUnpin for WriteBehindQueue
impl UnwindSafe for WriteBehindQueue
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
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> 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 more