Skip to main content

ChronixConfig

Struct ChronixConfig 

Source
pub struct ChronixConfig {
Show 27 fields pub data_dir: PathBuf, pub wal: WalConfig, pub memtable_flush_threshold: usize, pub max_memtable_memory: usize, pub shard_duration: Duration, pub ooo_shard_tolerance: u32, pub retention: Option<Duration>, pub measurement_retention: HashMap<String, Duration>, pub compression: CompressionCodec, pub zstd_level: i32, pub zstd_dict_training: bool, pub float_encoding: FloatEncoding, pub segment_cache_size: usize, pub cdc_capacity: usize, pub enable_last_value_cache: bool, pub lvc_measurements: Option<HashSet<String>>, pub compaction_concurrency: usize, pub maintenance_interval: Duration, pub max_series_cardinality: usize, pub max_query_result_bytes: usize, pub per_query_memory_limit: usize, pub query_timeout: Duration, pub analytics: AnalyticsConfig, pub soft_delete_ttl: Option<Duration>, pub future_write_tolerance: Duration, pub field_encryption: FieldEncryption, pub checkpoints: Checkpoints,
}
Expand description

Top-level database configuration.

Constructed via the builder pattern: ChronixConfig::builder(). Every field defaults, so a TOML file may set only what it changes.

Without this, from_toml required all twenty-five settings to be present and answered a file that set only data_dir with TOML parse error at line 1, column 1 — no field named, no hint. There is no such thing as a config file a person writes that lists every setting, so the loader could not load anything anybody would write.

deny_unknown_fields stays: a key that is misspelled must still be an error, because a silently ignored setting is the failure this whole file has been bitten by.

Fields§

§data_dir: PathBuf

Path to the data directory.

§wal: WalConfig

WAL configuration.

§memtable_flush_threshold: usize

Memtable flush threshold in bytes (default: 64 MB).

§max_memtable_memory: usize

Maximum total memtable memory across active + frozen (default: 256 MB).

§shard_duration: Duration

Time-shard duration (default: 1 hour).

§ooo_shard_tolerance: u32

Out-of-order tolerance in shard units (default: 2).

§retention: Option<Duration>

Retention period, enforced by the background compaction pass.

None — the default — keeps data forever. A database that deletes data by default is a database that deletes data nobody asked it to; retention is opt-in, exactly as it is in InfluxDB and SQLite-shaped stores, and unlike a scrape server.

§measurement_retention: HashMap<String, Duration>

Per-measurement retention overrides.

§compression: CompressionCodec

Compression codec for segments (default: LZ4).

§zstd_level: i32

Zstd compression level for new segments (1–22, default: 3).

Only meaningful when compression is Zstd. Higher is smaller and slower; cold-tier re-compression uses 9.

§zstd_dict_training: bool

Train a Zstd dictionary from the first row group of each segment (default: false).

The writer collects the first row group’s encoded blocks as training samples and, if there is enough of them (≥ 8 blocks, ≥ 16 KiB), compresses every later row group against the trained dictionary, storing it in the segment metadata for the reader. It helps most where blocks are small and repetitive, and costs a training pass per segment.

Only meaningful when compression is Zstd.

§float_encoding: FloatEncoding

Float encoding algorithm (default: Chimp).

§segment_cache_size: usize

Segment cache size in bytes (default: 512 MB).

§cdc_capacity: usize

CDC event-bus capacity — events buffered before the oldest are dropped for a slow subscriber (default: 65 536).

The ring costs capacity × ~112 bytes and is allocated on the first subscription, so a deployment that never reads the CDC stream pays nothing. The default is ~7 MiB, sized for a server; ChronixConfig::small sets 4 096.

§enable_last_value_cache: bool

Enable Last Value Cache (default: false).

§lvc_measurements: Option<HashSet<String>>

Per-measurement LVC opt-in. When Some, only listed measurements participate in the LVC. When None, all measurements use the LVC (provided enable_last_value_cache is true).

§compaction_concurrency: usize

Maximum concurrent compaction tasks (default: 2).

§maintenance_interval: Duration

How often the built-in maintenance thread compacts, materialises rollups, collects garbage and enforces retention (default: 30 s).

Flushes are not on this schedule — the thread flushes as soon as a memtable crosses its threshold. Duration::ZERO disables the periodic passes (flush-on-demand stays), for a caller that runs compact() and enforce_retention() on its own schedule.

§max_series_cardinality: usize

Maximum number of distinct series in the database (default: 1M).

§max_query_result_bytes: usize

Maximum query result size in bytes (default: 256 MB, 0 = unlimited). Queries whose intermediate batches exceed this are aborted early.

§per_query_memory_limit: usize

Per-query memory budget in bytes (default: 256 MiB, 0 = unlimited).

Each query execution creates a MemoryTracker with this budget. Intermediate allocations (collected RecordBatches) are charged against the tracker; if the budget is exceeded the query fails with QueryMemoryExceeded instead of causing OOM.

§query_timeout: Duration

Query execution timeout (default: 60s, Duration::ZERO = no timeout).

Queries that exceed this duration are aborted with a QueryTimeout error to prevent runaway scans.

§analytics: AnalyticsConfig

Analytics engine configuration.

§soft_delete_ttl: Option<Duration>

Soft-delete TTL for dropped measurements.

When set, drop_measurement marks the measurement as “pending deletion” with a deadline instead of immediately removing its segments. A background GC pass hard-deletes measurements that have been pending longer than this TTL, allowing accidental drops to be recovered within the grace window.

Default: None (immediate hard-delete, original behaviour).

§future_write_tolerance: Duration

How far ahead of the wall clock a point’s timestamp may be (default: 1 hour).

A point beyond this is rejected before admission, on every write path including backfill. The out-of-order window is anchored on the newest admitted timestamp, so without this bound one point from a device with a broken clock would move the window years into the future and every real write after it would be rejected until the next restart.

§field_encryption: FieldEncryption

Per-column encryption in the segment format — see FieldEncryption.

Empty by default: nothing is encrypted, and the data directory is the filesystem’s job.

§checkpoints: Checkpoints

Take a checkpoint on a schedule — see Checkpoints.

Off by default. A backup is a policy decision, and a database that starts writing copies of itself somewhere the operator did not ask for is worse than one that does nothing.

Implementations§

Source§

impl ChronixConfig

Source

pub fn small(data_dir: impl Into<PathBuf>) -> Self

Returns a builder with sensible defaults. A configuration preset for small-footprint deployments — IoT gateways and edge devices with 512 MB–1 GB of RAM and flash (eMMC/SD) storage.

Compared to the default configuration:

  • Memory budget ≈ 48 MB — 8 MB memtable flush threshold, 24 MB total memtable budget, 16 MB segment cache.
  • Flash-friendly WAL — Periodic(5s) fsync coalesces syncs to reduce write amplification and flash wear; up to ~5 s of the most recent writes may be lost on power failure. Choose FsyncPolicy::PerBatch instead if that is not acceptable.
  • Single compaction worker — bounds background CPU and I/O.

All fields remain overridable after construction.

Source

pub fn builder() -> ChronixConfigBuilder

Returns a builder with sensible defaults.

Source

pub fn from_toml(path: &Path) -> Result<Self, ConfigError>

Load configuration from a TOML file, then apply builder overrides.

§Errors

Returns ConfigError if the file cannot be read, parsed, or fails validation.

Source

pub fn validate(&self) -> Result<(), ConfigError>

Validate configuration invariants.

Called by from_toml and ChronixConfigBuilder::build to enforce structural invariants on the final configuration.

§Errors

Returns ConfigError when any field is out of range or internally inconsistent (see the individual checks).

Trait Implementations§

Source§

impl Clone for ChronixConfig

Source§

fn clone(&self) -> ChronixConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChronixConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChronixConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ChronixConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ChronixConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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