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 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)
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).
Unparseable values log a warning and fall back to defaults — boot doesn’t fail.
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.