pub struct ChronixConfig {Show 25 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,
}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: PathBufPath to the data directory.
wal: WalConfigWAL configuration.
memtable_flush_threshold: usizeMemtable flush threshold in bytes (default: 64 MB).
max_memtable_memory: usizeMaximum total memtable memory across active + frozen (default: 256 MB).
shard_duration: DurationTime-shard duration (default: 1 hour).
ooo_shard_tolerance: u32Out-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: CompressionCodecCompression codec for segments (default: LZ4).
zstd_level: i32Zstd 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: boolTrain 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: FloatEncodingFloat encoding algorithm (default: Chimp).
segment_cache_size: usizeSegment cache size in bytes (default: 512 MB).
cdc_capacity: usizeCDC 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: boolEnable 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: usizeMaximum concurrent compaction tasks (default: 2).
maintenance_interval: DurationHow 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: usizeMaximum number of distinct series in the database (default: 1M).
max_query_result_bytes: usizeMaximum query result size in bytes (default: 256 MB, 0 = unlimited). Queries whose intermediate batches exceed this are aborted early.
per_query_memory_limit: usizePer-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: DurationQuery execution timeout (default: 60s, Duration::ZERO = no timeout).
Queries that exceed this duration are aborted with a
QueryTimeout error to prevent runaway scans.
analytics: AnalyticsConfigAnalytics 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: DurationHow 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.
Implementations§
Source§impl ChronixConfig
impl ChronixConfig
Sourcepub fn small(data_dir: impl Into<PathBuf>) -> Self
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. ChooseFsyncPolicy::PerBatchinstead if that is not acceptable. - Single compaction worker — bounds background CPU and I/O.
All fields remain overridable after construction.
Sourcepub fn builder() -> ChronixConfigBuilder
pub fn builder() -> ChronixConfigBuilder
Returns a builder with sensible defaults.
Sourcepub fn from_toml(path: &Path) -> Result<Self, ConfigError>
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.
Sourcepub fn validate(&self) -> Result<(), ConfigError>
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
impl Clone for ChronixConfig
Source§fn clone(&self) -> ChronixConfig
fn clone(&self) -> ChronixConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more