lifecycle

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 6 Imported by: 0

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

type ArchivalConfig struct {
	MaxAgeDays      int
	MinArchiveScore float64
	CheckInterval   time.Duration
}

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

Start begins periodic archival checks in a background goroutine. Returns a cancel function to stop the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL