pub struct Engine {
pub(crate) db: DBWithThreadMode<MultiThreaded>,
pub(crate) pool: Arc<Pool>,
pub(crate) ctx: Arc<Context>,
pub(crate) read_only: bool,
pub(crate) secondary: bool,
pub(crate) checksums: bool,
pub(crate) write_options: WriteOptions,
cf_index: OnceLock<BTreeMap<u32, Weak<Map>>>,
corks: AtomicU32,
}Expand description
Handle to the opened RocksDB database and its shared resources.
One Engine exists per database, shared behind an Arc by every Map.
Fields§
§db: DBWithThreadMode<MultiThreaded>The opened RocksDB instance.
pool: Arc<Pool>Thread pool offloading uncached, blocking database requests from the tokio workers.
ctx: Arc<Context>Resources constructed before the database is opened and outliving it (block caches, environment, column descriptors).
read_only: boolDatabase was opened read-only; writes are rejected.
secondary: boolDatabase was opened as a secondary follower of a primary instance.
checksums: boolVerify block checksums on read.
write_options: WriteOptionsShared write options for atomic batch commits.
cf_index: OnceLock<BTreeMap<u32, Weak<Map>>>Resolves catalog column ids for post-commit watcher notification. Runtime migration column families are intentionally absent.
corks: AtomicU32Live cork count; nonzero suppresses the per-write WAL flush.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn backup(&self) -> Result
pub fn backup(&self) -> Result
Creates a RocksDB backup of the current database.
Writable engines flush before snapshotting, while read-only engines back up their current view without a flush. Old backups are then purged to the configured retention count; a purge failure is logged without failing the newly created backup.
§Panics
Panics if RocksDB reports successful creation without returning metadata for the new backup.
Source§impl Engine
impl Engine
Sourcepub fn backup_purge(&self, keep: usize) -> Result
pub fn backup_purge(&self, keep: usize) -> Result
Deletes old backups while retaining the newest keep entries.
Passing zero removes every backup known to the backup engine. Retention and deletion are delegated to RocksDB’s backup repository.
Source§impl Engine
impl Engine
Sourcepub fn backup_count(&self) -> Result<usize>
pub fn backup_count(&self) -> Result<usize>
Returns the number of backups currently recorded.
The count comes from RocksDB’s backup metadata. An empty repository produces zero.
Source§impl Engine
impl Engine
Sourcepub fn backup_verify(&self, backup_id: u32) -> Result<u32>
pub fn backup_verify(&self, backup_id: u32) -> Result<u32>
Verifies the integrity of a RocksDB backup.
Identifier zero selects the most recent backup; any other identifier selects that exact entry. The verified backup identifier is returned on success.
Source§impl Engine
impl Engine
Sourcepub fn memory_usage(&self) -> Result<String>
pub fn memory_usage(&self) -> Result<String>
Formats the database engine’s current memory usage.
The report covers memtables, pending writes, table readers, and the row cache. When column-cache pools exist, it also includes their usage, capacity, pinned memory, and participating column-family counts.
Source§impl Engine
impl Engine
fn configure_cfds( ctx: &Arc<Context>, db_opts: &Options, desc: &[Descriptor], ) -> Result<(Vec<ColumnFamilyDescriptor>, Vec<String>)>
Source§impl Engine
impl Engine
Sourcepub fn wait_compactions_blocking(&self) -> Result
pub fn wait_compactions_blocking(&self) -> Result
Block until outstanding background compactions finish.
Waits without a timeout and does not flush first; aborts the wait if compaction has been paused.
Sourcepub fn sort(&self) -> Result
pub fn sort(&self) -> Result
Flush the memtables to SST files (a RocksDB LSM-tree flush).
Forces buffered writes out of memory into the on-disk LSM tree. An LSM
flush, not a libc fflush(3) or fsync(2), and distinct from the
flush and sync methods here, which act on the write-ahead log.
Sourcepub fn update(&self) -> Result
pub fn update(&self) -> Result
Catch a secondary instance up to the primary’s latest writes.
Replays the primary’s newly appended WAL into this instance’s view; meaningful only when the database was opened as a secondary.
Sourcepub fn sync(&self) -> Result
pub fn sync(&self) -> Result
Flush the write-ahead log and fsync it to disk.
Once this returns the buffered writes survive power loss. Heavier than
flush, which stops at the OS page cache.
Sourcepub fn flush(&self) -> Result
pub fn flush(&self) -> Result
Flush the buffered write-ahead log to the OS without an fsync.
Pushes WAL bytes to the page cache (durable against process crash, not power loss). This is the per-write flush that corking suppresses.
Sourcepub fn corked(&self) -> bool
pub fn corked(&self) -> bool
Whether any cork is currently held.
When true, Map insert and remove skip their post-write WAL flush so
the records coalesce into one batch. Corking is purely a backend
write-buffering signal: it never changes application logic or any
observable database API behavior, because a write lands in the memtable
synchronously and reads back regardless of WAL flush state. See the
cork module.
Sourcepub(crate) fn property_integer(
&self,
cf: &impl AsColumnFamilyRef,
name: &CStr,
) -> Result<u64>
pub(crate) fn property_integer( &self, cf: &impl AsColumnFamilyRef, name: &CStr, ) -> Result<u64>
Query for database property by null-terminated name which is expected to have a result with an integer representation. This is intended for low-overhead programmatic use.
Sourcepub(crate) fn property(
&self,
cf: &impl AsColumnFamilyRef,
name: &str,
) -> Result<String>
pub(crate) fn property( &self, cf: &impl AsColumnFamilyRef, name: &str, ) -> Result<String>
Query for database property by name receiving the result in a string.
Sourcepub(crate) fn cf(&self, name: &str) -> Arc<BoundColumnFamily<'_>> ⓘ
pub(crate) fn cf(&self, name: &str) -> Arc<BoundColumnFamily<'_>> ⓘ
Look up a column-family handle by name.
The handle refers to a family opened with this database and remains tied to the engine’s lifetime.
§Panics
Panics if the family was not described before the database was opened.
Sourcepub fn has_cf(&self, name: &str) -> bool
pub fn has_cf(&self, name: &str) -> bool
Reports whether a column family with this name exists.
The lookup consults the handles currently opened by RocksDB. It does not create a missing family.
Sourcepub fn current_sequence(&self) -> u64
pub fn current_sequence(&self) -> u64
Returns the latest RocksDB sequence number.
RocksDB assigns sequence numbers to committed writes, so this value marks the engine’s current write position. The number is local to this database.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Reports whether this engine rejects writes.
Both read-only and secondary opens reject writes through their database handle. A writable primary open returns false.
Sourcepub fn is_secondary(&self) -> bool
pub fn is_secondary(&self) -> bool
Reports whether the database follows a primary as a secondary.
A secondary advances its view when Self::update catches up with the
primary. Writes through the secondary handle are rejected.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
rhs with checked arithmetic. Read more