pub struct CompactionConfig {
pub min_files_to_compact: usize,
pub target_file_size: usize,
pub max_file_size: usize,
pub small_file_threshold: usize,
pub max_input_bytes_per_snapshot: u64,
pub max_input_files_per_snapshot: usize,
pub max_pass_seconds: u64,
pub compaction_interval_seconds: u64,
pub auto_compact: bool,
pub strategy: CompactionStrategy,
pub retention: RetentionConfig,
pub archive: Option<Arc<dyn ArchiveTarget>>,
}Fields§
§min_files_to_compact: usizeMinimum number of files to trigger compaction
target_file_size: usizeTarget size for compacted files (in bytes)
max_file_size: usizeMaximum size for a single compacted file (in bytes)
small_file_threshold: usizeMinimum file size to consider for compaction (small files)
max_input_bytes_per_snapshot: u64Compressed input bytes one snapshot may be built from.
A group’s events are all resident at once, and decoding this archive shape costs roughly 16× its on-disk size, so this is the term that bounds a compaction pass’s peak memory. A tenant whose candidates exceed it is compacted into several snapshots instead of one.
max_input_files_per_snapshot: usizeInput files one snapshot may be built from, bounding footer opens and path bookkeeping independently of how small the files are.
max_pass_seconds: u64Wall-clock budget for one compaction sweep. Checked between groups, so a sweep overruns by at most one group.
A backlog is resumed on the next tick rather than drained in one pass: the first sweep over an uncompacted tenant has as many groups as the tenant has, and an unbounded sweep would hold CPU and disk for as long as that takes.
compaction_interval_seconds: u64Time interval between automatic compactions (in seconds)
auto_compact: boolEnable automatic background compaction
strategy: CompactionStrategyCompaction strategy
retention: RetentionConfigPer-tenant retention TTLs (Step 5 of the sustainable data
strategy). Applied during the same compaction pass — events
older than now - ttl for that tenant are dropped from the
snapshot output and the originals are removed. Default
honors the bead: tenant system keeps 30 days; everyone
else keeps forever.
archive: Option<Arc<dyn ArchiveTarget>>Optional cold-tier archive. When set, events that would be
dropped by retention are archived to this target BEFORE the
originals are deleted. A failed archive aborts the
compaction pass — originals stay on disk and the next run
retries. Default None preserves the pre-cold-tier behavior:
retention deletes outright. See
infrastructure::persistence::cold_tier.
Implementations§
Source§impl CompactionConfig
impl CompactionConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Build a config from the relevant env vars:
ALLSOURCE_SNAPSHOT_INTERVAL_SECONDS: per-pass cadence (default 3600).ALLSOURCE_RETENTION_SYSTEM_DAYS: TTL for thesystemtenant in days (default 30).ALLSOURCE_COMPACTION_INPUT_BYTES: compressed input bytes per snapshot, which bounds a pass’s peak memory (default 32 MiB).
Unparseable values log a warning and fall back to defaults — boot doesn’t fail.
Sourcepub fn with_input_bytes(self, bytes_var: Option<String>) -> Self
pub fn with_input_bytes(self, bytes_var: Option<String>) -> Self
Override max_input_bytes_per_snapshot. Zero is rejected: it would
make every file its own group and rewrite the tenant file-for-file.
Sourcepub fn with_cold_storage_url(self, url: Option<String>) -> Self
pub fn with_cold_storage_url(self, url: Option<String>) -> Self
Attach a cold-tier archive from ALLSOURCE_COLD_STORAGE_URL
(s3://bucket/prefix). Unset or empty leaves archive as None,
which is the default: retention deletes without archiving.
A URL that is set but unusable is a hard error, not a warning. Every other env var here falls back to a default because a wrong interval costs a slow pass; this one decides whether events are copied somewhere before compaction deletes the originals, so degrading to “no archive” would turn an operator’s typo into silent data loss.
Sourcepub fn from_env_vars(
interval_var: Option<String>,
system_retention_days_var: Option<String>,
) -> Self
pub fn from_env_vars( interval_var: Option<String>, system_retention_days_var: Option<String>, ) -> Self
Testable variant of from_env. Production calls from_env;
tests pass explicit values.
Sourcepub fn from_env_var(interval_var: Option<String>) -> Self
pub fn from_env_var(interval_var: Option<String>) -> Self
Backwards-compatible single-arg variant for existing callers that only set the snapshot interval.