Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }

Implementations§

Source§

impl Engine

Source

pub fn spawn_background_maintenance(&self) -> Option<JoinHandle<()>>

Spawn a background maintenance task that periodically flushes the memtable to SSTable, runs compaction, and garbage-collects expired SST files. The task runs until the returned JoinHandle is dropped or the engine is shut down.

This should be called once after Engine::open when running inside a Tokio runtime.

Source

pub async fn open(config: Config) -> Result<Self>

Source

pub fn write_batch(&self, batch: &[Record]) -> Result<()>

Source

pub fn write_batch_owned(&self, batch: Vec<Record>) -> Result<()>

Source

pub fn write_batch_sync(&self, batch: Vec<Record>) -> Result<()>

Source

pub fn write_batch_ttl( &self, batch: &[Record], ttl_secs: Option<u64>, ) -> Result<()>

Source

pub async fn query(&self, query: Query) -> Result<Vec<Record>>

Source

pub async fn query_by_prefix(&self, key: &str) -> Result<Vec<Record>>

Source

pub async fn query_by_key_range( &self, start: &str, end: &str, ) -> Result<Vec<Record>>

Source

pub async fn query_time_range( &self, start: i64, end: i64, ) -> Result<Vec<Record>>

Source

pub async fn query_prefix_time_range( &self, key: &str, start: i64, end: i64, ) -> Result<Vec<Record>>

Source

pub async fn query_key_time_range( &self, start_key: &str, end_key: &str, start: i64, end: i64, ) -> Result<Vec<Record>>

Source

pub async fn get(&self, key: &str, ts: i64) -> Result<Option<Record>>

Source

pub fn get_sync(&self, key: &str, ts: i64) -> Option<Record>

Source

pub fn delete_batch(&self, keys_ts: &[(String, i64)]) -> Result<()>

Source

pub fn delete_range(&self, start_key: &str, end_key: &str) -> Result<()>

Source

pub fn patch_record( &self, key: &str, ts: i64, new_value: Option<Vec<u8>>, new_ttl_secs: Option<u64>, ) -> Result<Record>

Source

pub fn stats(&self) -> EngineStats

Source

pub fn metrics_text(&self) -> String

Source

pub async fn flush(&self) -> Result<()>

Source

pub async fn trigger_gc(&self) -> Result<u64>

Source

pub async fn trigger_compaction(&self) -> Result<bool>

Source

pub async fn shutdown(self) -> Result<()>

Shut down the engine, flushing the memtable and WAL. Consumes self — use Engine::close if the engine is behind an Arc.

Source

pub async fn close(&self) -> Result<()>

Flush the memtable and WAL without consuming self.

This is the Arc<Engine>-friendly alternative to shutdown. Use it from server binaries that share the engine across tasks/handlers. The background maintenance task (if any) is NOT stopped — call abort() on the handle returned by spawn_background_maintenance first, or simply drop the JoinHandle.

Source

pub fn scan(&self, range: ScanRange) -> Result<ScanIterator>

Lazy iterator scan with default ReadOptions.

Source

pub fn scan_opt( &self, range: ScanRange, _opts: &ReadOptions, ) -> Result<ScanIterator>

Lazy iterator scan with caller-provided ReadOptions.

Source

pub fn scan_prefix(&self, prefix: &str) -> Result<ScanIterator>

Convenience: prefix scan returning a lazy iterator.

Source

pub fn scan_prefix_time_range( &self, prefix: &str, ts_start: i64, ts_end: i64, ) -> Result<ScanIterator>

Convenience: prefix + time-range scan returning a lazy iterator.

Source

pub fn get_latest(&self, key: &str) -> Result<Option<Record>>

Get the latest record for a given key (highest ts). Uses a bounded prefix scan and returns the last record.

Source

pub async fn get_latest_async(&self, key: &str) -> Result<Option<Record>>

Async wrapper for get_latest.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more