temperature

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Score

func Score(relevance, temperature float64) float64

Temperature-weighted relevance: cold nodes deprioritized but still findable.

Types

type ColdHandler

type ColdHandler func(ctx context.Context, nodes []*store.Node)

type Config

type Config struct {
	DecayRate        float64
	AccessBoost      float64
	HotThreshold     float64
	ColdThreshold    float64
	NotifyThreshold  float64
	SummarizeRebound float64
	TickInterval     time.Duration
	ColdNotifyTTL    time.Duration
	ColdNotifyLimit  int
	Enabled          bool
}

func DefaultConfig

func DefaultConfig() Config

func (Config) Validate added in v0.1.4

func (c Config) Validate() error

func (Config) WithOverrides added in v0.3.4

func (c Config) WithOverrides(o config.TemperatureConfig) Config

Apply a config.json temperature block over c; nil fields keep c's value.

type NodeStore

type NodeStore interface {
	BoostTemperatureBatch(ctx context.Context, ids []string, boost float64) error
	DecayTemperatures(ctx context.Context, factor float64) (int64, error)
	GetColdNodes(ctx context.Context, threshold float64, limit int) ([]*store.Node, error)
}

type TickResult

type TickResult struct {
	Decayed int64
	Cold    []*store.Node
}

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(s NodeStore, dir string, bootstrap Config, logger *slog.Logger) (*Tracker, error)

func (*Tracker) MarkNotified added in v0.1.4

func (t *Tracker) MarkNotified(ids []string)

Stamp ids as notified at time.Now(); pair with dedupCold after a successful send.

func (*Tracker) RecordAccess

func (t *Tracker) RecordAccess(ctx context.Context, ids []string) error

func (*Tracker) Run

func (t *Tracker) Run(ctx context.Context, handler ColdHandler)

func (*Tracker) SetTickObserver added in v0.3.4

func (t *Tracker) SetTickObserver(fn func())

SetTickObserver sets a callback fired after each tick that decayed a node, set before Run (nil disables).

func (*Tracker) Tick

func (t *Tracker) Tick(ctx context.Context, elapsed time.Duration) (*TickResult, error)

Jump to

Keyboard shortcuts

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