Documentation
¶
Overview ¶
Package retention provides explicit storage policies and an immutable local cold-content store. It does not choose which application state is safe to archive, delete archives, call providers, or schedule background work.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Budget ¶
type Budget struct {
Items int `json:"items"`
Bytes int64 `json:"bytes"`
Deferred bool `json:"deferred"`
Reason string `json:"reason"`
}
Budget limits the next maintenance batch only. It does not change the eligibility rules for content or represent an OS resource reservation.
type ColdStore ¶
ColdStore stores immutable content-addressed gzip files in a private local directory. MaxBytes charges all regular data files, including unreferenced blobs, unknown files and interrupted temporary writes. It is a logical byte limit, not filesystem block accounting. There is deliberately no deletion API.
func (ColdStore) Inventory ¶
Inventory uses bounded directory pages and fails closed on unsafe entries or excessive file counts. A missing directory is an empty inventory; no files or directories are created in that case.
func (ColdStore) Put ¶
Put durably publishes one content-addressed file before returning its reference. A per-directory process lock serializes quota checks across stores and databases sharing the directory. An existing file is verified and never overwritten. A failed or canceled call can leave an unreferenced durable blob; callers must never infer that an error authorizes deleting its final name.
type Config ¶
type Config struct {
Schema int `json:"schema"`
ColdDir string `json:"cold_dir"`
HotHistoryDays int `json:"hot_history_days"`
KeepRecentVersions int `json:"keep_recent_versions"`
ArchiveCompletedCurrent bool `json:"archive_completed_current"`
MaxDatabaseBytes int64 `json:"max_database_bytes"`
MaxColdBytes int64 `json:"max_cold_bytes"`
BatchItems int `json:"batch_items"`
BatchBytes int64 `json:"batch_bytes"`
Adaptive bool `json:"adaptive"`
MinFreeMemoryBytes int64 `json:"min_free_memory_bytes"`
MemoryPercent int64 `json:"memory_percent"`
MaxCPULoadMilli int64 `json:"max_cpu_load_milli"`
}
Config is a complete opt-in policy. MaxDatabaseBytes may be zero for an explicit unlimited hot database; cold storage always has a positive limit. Callers control when to run maintenance and whether to apply a proposed batch.
func Decode ¶
Decode accepts one complete, bounded JSON object. Duplicate, missing, unknown and null fields are rejected, including explicitly false policy switches.
func DefaultConfig ¶
type Event ¶
type Event struct {
Operation string `json:"operation"`
Outcome string `json:"outcome"`
ErrorCode string `json:"error_code,omitempty"`
StartedAt time.Time `json:"started_at"`
EndedAt time.Time `json:"ended_at"`
Items int64 `json:"items"`
Bytes int64 `json:"bytes"`
}
Event carries maintenance measurements only. It deliberately has no paths, content, digests, keys, tokens, exception messages or provider data.