Documentation
¶
Overview ¶
Package lifecycle implements auto-archival and lifecycle management for Cortex.
The archival service periodically checks for observations that are old and have low importance scores, soft-deleting them to keep the memory store focused.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchivalConfig ¶
ArchivalConfig holds configuration for the archival service.
type ArchivalRepository ¶
type ArchivalRepository interface {
// ListArchivable retrieves observations older than cutoff with score below minScore.
ListArchivable(ctx context.Context, cutoff time.Time, minScore float64, limit int) ([]*domain.Observation, error)
// Delete soft-deletes an observation.
Delete(ctx context.Context, id int64) error
}
ArchivalRepository defines the store methods needed for auto-archival.
type ArchivalService ¶
type ArchivalService struct {
// contains filtered or unexported fields
}
ArchivalService manages automatic archival of low-importance observations.
func NewArchivalService ¶
func NewArchivalService(repo ArchivalRepository, cfg ArchivalConfig) *ArchivalService
NewArchivalService creates a new archival service.
func (*ArchivalService) RunArchivalCheck ¶
func (s *ArchivalService) RunArchivalCheck(ctx context.Context) (int, error)
RunArchivalCheck checks all observations and archives those that are old enough and have a score below the minimum threshold.
func (*ArchivalService) SetNowFunc ¶
func (s *ArchivalService) SetNowFunc(fn func() time.Time)
SetNowFunc allows injecting a custom time function for testing.
func (*ArchivalService) Start ¶
func (s *ArchivalService) Start(ctx context.Context) context.CancelFunc
Start begins periodic archival checks in a background goroutine. Returns a cancel function to stop the service.