pub struct LiteConfig {Show 23 fields
pub memory_budget: usize,
pub hnsw_percent: usize,
pub csr_percent: usize,
pub loro_percent: usize,
pub query_percent: usize,
pub kv_percent: usize,
pub document_percent: usize,
pub strict_percent: usize,
pub columnar_percent: usize,
pub timeseries_percent: usize,
pub spatial_percent: usize,
pub fts_percent: usize,
pub array_percent: usize,
pub sparse_percent: usize,
pub sync_enabled: bool,
pub argon2_m_cost: u32,
pub argon2_t_cost: u32,
pub argon2_p_cost: u32,
pub kv_cache_capacity: usize,
pub outbound_queue_cap: usize,
pub auto_flush_ms: u64,
pub auto_compact_ms: u64,
pub corruption_policy: CorruptionPolicy,
}Expand description
Runtime configuration for a NodeDB-Lite instance.
All percentage fields express a fraction of memory_budget allocated to
the corresponding engine. The remaining percentage is headroom (untracked).
§Example
use nodedb_lite::config::LiteConfig;
let cfg = LiteConfig {
memory_budget: 256 * 1024 * 1024, // 256 MiB
..LiteConfig::default()
};Fields§
§memory_budget: usizeTotal memory budget in bytes. Default: 100 MiB.
hnsw_percent: usizePercentage of memory_budget reserved for HNSW vector index. Default: 40.
csr_percent: usizePercentage of memory_budget reserved for CSR graph index. Default: 15.
loro_percent: usizePercentage of memory_budget reserved for Loro CRDT engine. Default: 15.
query_percent: usizePercentage of memory_budget reserved for query scratch space. Default: 15.
kv_percent: usizePercentage of memory_budget reserved for the key-value engine. Default: 2.
document_percent: usizePercentage of memory_budget reserved for the schemaless document engine. Default: 2.
strict_percent: usizePercentage of memory_budget reserved for the strict document engine. Default: 2.
columnar_percent: usizePercentage of memory_budget reserved for the columnar engine. Default: 2.
timeseries_percent: usizePercentage of memory_budget reserved for the timeseries engine. Default: 1.
spatial_percent: usizePercentage of memory_budget reserved for the spatial engine. Default: 1.
fts_percent: usizePercentage of memory_budget reserved for the full-text search engine. Default: 1.
array_percent: usizePercentage of memory_budget reserved for the array engine. Default: 1.
sparse_percent: usizePercentage of memory_budget reserved for the sparse-vector metadata engine. Default: 1.
sync_enabled: boolOpen the durable outbound sync queues. Default: true.
When true, KV, columnar, timeseries, vector, FTS and spatial writes
record themselves in their outbound queue, and the push loop sends
them to Origin. When false, those writes stay local. Documents sync
through Loro either way.
argon2_m_cost: u32Argon2id memory cost in KiB. Default: 19 MiB (19_456 KiB). Corresponds to the OWASP recommended minimum for interactive login.
argon2_t_cost: u32Argon2id iteration count. Default: 2.
argon2_p_cost: u32Argon2id parallelism lanes. Default: 1.
kv_cache_capacity: usizeMaximum entries in the in-memory KV read cache. Default: 10_000.
Each entry holds the raw encoded value (typically ~80 bytes for a 64-byte payload + 8-byte TTL framing), so 10 000 entries ≈ 800 KB.
A value of 0 is rejected at open time; use 1 as the effective minimum.
outbound_queue_cap: usizeMaximum number of pending entries in each durable outbound queue (columnar and timeseries). Default: 100_000.
When a queue reaches this cap, write operations return
[LiteError::Backpressure] until the sync transport drains entries.
This bounds RAM usage to the key/pointer overhead regardless of how
long the device stays offline; the payloads themselves are on disk.
Can also be set via the NODEDB_LITE_OUTBOUND_QUEUE_CAP environment
variable.
auto_flush_ms: u64Scheduled interval between background flushes, in milliseconds. Default: 1000 (one second).
Opening a database starts a task that applies buffered document, CRDT, and KV state and persists derived checkpoints. Scheduling delays and storage errors prevent a hard wall-clock durability bound. The task stops when the last database handle disappears.
Strict row writes commit before success. Native filesystem pagedb commits survive reopening without an explicit flush. Generic storage backends provide their own commit durability guarantees. Unindexed KV puts and all KV deletes remain buffered. Indexed KV puts and SQL KV writes commit directly. Derived checkpoint maintenance remains separate from strict commits. Later maintenance errors do not roll back committed rows.
Set to 0 to disable background flushing. Call flush() before dropping buffered state.
auto_compact_ms: u64Interval between automatic background compactions, in milliseconds. Default: 0 (disabled).
When non-zero, opening a database spawns a background task that calls
the global compact() every auto_compact_ms milliseconds, reclaiming
dead pages and truncating the backing file to bound on-disk growth.
Unlike auto-flush this is opt-in: compaction is a heavier operation
(it repacks B+ trees and truncates the file, and no-ops while a reader
pins the reclaimable range), so it is not imposed on every embedder by
default.
Enable it when writing one commit per entry (where the deferred-free
list would otherwise grow unbounded). A much larger interval than
auto_flush_ms is appropriate — e.g. minutes, not seconds. Set to 0 to
leave compaction fully manual via compact().
corruption_policy: CorruptionPolicyWhat to do when the store being opened cannot be read.
Default: CorruptionPolicy::FailClosed.
The default refuses to open and leaves the damaged store untouched, so
an embedder that has no Origin to re-sync from does not silently start
against an empty database. Selecting
CorruptionPolicy::DiscardStoreAndRecreate is a statement that the
data can be rebuilt from somewhere else.
Implementations§
Source§impl LiteConfig
impl LiteConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Load configuration from environment variables, falling back to defaults for any variable that is absent or malformed.
Handled variables:
NODEDB_LITE_MEMORY_MB— total memory budget in mebibytes (parsed asusize)NODEDB_LITE_AUTO_FLUSH_MS— auto-flush interval in milliseconds (parsed asu64; 0 = disabled)NODEDB_LITE_AUTO_COMPACT_MS— auto-compact interval in milliseconds (parsed asu64; 0 = disabled, the default)NODEDB_LITE_OUTBOUND_QUEUE_CAP— max pending entries per durable outbound queue (parsed asusize; must be > 0)
Source§impl LiteConfig
impl LiteConfig
Sourcepub fn to_governor_config(&self) -> GovernorConfig
pub fn to_governor_config(&self) -> GovernorConfig
Build a GovernorConfig from this config’s budget and percentages.
Every _percent field maps to one EngineId Lite runs. Wal and
Bridge get a zero limit: Lite has no WAL crate and no cross-plane
bridge, so neither engine ever allocates here.
Source§impl LiteConfig
impl LiteConfig
Sourcepub fn validate(&self) -> NodeDbResult<()>
pub fn validate(&self) -> NodeDbResult<()>
Validate that percentage fields are coherent.
Returns an error if:
- Any individual percentage exceeds 100
- The sum of all engine percentages exceeds
MAX_TOTAL_ENGINE_PERCENT
Trait Implementations§
Source§impl Clone for LiteConfig
impl Clone for LiteConfig
Source§impl Debug for LiteConfig
impl Debug for LiteConfig
Source§impl Default for LiteConfig
impl Default for LiteConfig
Source§impl<'de> Deserialize<'de> for LiteConfig
impl<'de> Deserialize<'de> for LiteConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for LiteConfig
Source§impl PartialEq for LiteConfig
impl PartialEq for LiteConfig
Source§impl Serialize for LiteConfig
impl Serialize for LiteConfig
impl StructuralPartialEq for LiteConfig
Auto Trait Implementations§
impl Freeze for LiteConfig
impl RefUnwindSafe for LiteConfig
impl Send for LiteConfig
impl Sync for LiteConfig
impl Unpin for LiteConfig
impl UnsafeUnpin for LiteConfig
impl UnwindSafe for LiteConfig
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.impl<T> NodeDbMarker for T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§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();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§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();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§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();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§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();Source§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.
Source§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);Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Rleable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.