Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchiveTrigger ¶
type ArchiveTrigger int
ArchiveTrigger controls when journal files are archived.
const ( ArchiveDisabled ArchiveTrigger = iota ArchiveOnRotate // archive immediately after rotation ArchiveBeforeExpire // archive only when about to be deleted by retention )
func ParseArchiveTrigger ¶
func ParseArchiveTrigger(s string) (ArchiveTrigger, error)
ParseArchiveTrigger parses a string into an ArchiveTrigger.
func (ArchiveTrigger) String ¶
func (t ArchiveTrigger) String() string
String returns the string representation of an ArchiveTrigger.
type JournalKeeper ¶
type JournalKeeper struct {
// contains filtered or unexported fields
}
JournalKeeper manages journal file archival and retention. One goroutine per binary, driven by rotation notifications and periodic directory scans.
func NewJournalKeeper ¶
func NewJournalKeeper(cfg KeeperConfig) *JournalKeeper
NewJournalKeeper creates a keeper. Call Run to start.
func (*JournalKeeper) Run ¶
func (k *JournalKeeper) Run(ctx context.Context)
Run is the main loop. Blocks until ctx is cancelled.
func (*JournalKeeper) Send ¶
func (k *JournalKeeper) Send(rf RotatedFile)
Send notifies the keeper that a file was rotated. Non-blocking; drops if the channel is full (the periodic scan will pick it up).
func (*JournalKeeper) SetOnPauseChange ¶
func (k *JournalKeeper) SetOnPauseChange(fn func(dir KeeperDir, paused bool))
SetOnPauseChange sets the callback invoked when a directory's pause state transitions. Must be called before Run.
type KeeperConfig ¶
type KeeperConfig struct {
// Dirs to manage. Ignored if DirFunc is set.
Dirs []KeeperDir
// DirFunc returns current directories on each scan cycle.
// Used by cloud to dynamically discover instance dirs.
DirFunc func() []KeeperDir
// Retention
MaxAge time.Duration // 0 = no age limit
MinKeep time.Duration // 0 = no min-keep floor
MaxSize int64 // 0 = no size limit
// Soft/hard thresholds
SoftPct int // % of MaxSize for proactive archiving (default 80, range 1-99)
OverflowPolicy OverflowPolicy // what to do when hard cap hit with non-archived files
// Archive
ArchiveCommand string // path to script; empty = no archiving
ArchiveTrigger ArchiveTrigger // on-rotate or before-expire
// Pause callback (called when overflow-policy=pause-recording toggles state)
OnPauseChange func(dir KeeperDir, paused bool)
Logger *slog.Logger
}
KeeperConfig configures the JournalKeeper.
type OverflowPolicy ¶
type OverflowPolicy int
OverflowPolicy controls what happens when the hard size cap is hit and files haven't been archived yet.
const ( OverflowDeleteUnarchived OverflowPolicy = iota // delete files even if not archived OverflowPauseRecording // stop journal writes until archives free space )
func ParseOverflowPolicy ¶
func ParseOverflowPolicy(s string) (OverflowPolicy, error)
ParseOverflowPolicy parses a string into an OverflowPolicy.
func (OverflowPolicy) String ¶
func (p OverflowPolicy) String() string
String returns the string representation of an OverflowPolicy.
type RotatedFile ¶
RotatedFile describes a completed journal file.