Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLocked = errors.New("usage compaction locked")
ErrLocked is returned by Compact when another compaction holds a fresh lock.
var Ranges = []Range{ RangeAllTime, RangeLast1Day, RangeLast7Days, RangeLast30Days, RangeLast6Months, RangeLast1Year, }
Ranges lists the reporting windows in display order.
Functions ¶
This section is empty.
Types ¶
type ModelUsage ¶
type Record ¶
type Record struct {
TS time.Time
Date string
Provider, Model string
Input, Output, CacheRead, CacheWrite, Reasoning int
Rollup bool
}
Record is one ledger entry: either a raw per-response entry (TS set) or a rolled-up per-day entry (Date set, Rollup true).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func DefaultStore ¶
func (*Store) Compact ¶
Compact collapses every record into one rollup per (UTC day, provider, model) and drops rollups older than a year, rewriting the ledger atomically. Records without a usable timestamp are left untouched.
func (*Store) MaybeCompact ¶
MaybeCompact runs Compact at most once per UTC calendar day, tracking the last run in a marker file next to the ledger. It is a no-op when the ledger does not exist yet, so callers can invoke it on every startup cheaply.
type Summary ¶
type Summary struct {
Rows []ModelUsage
Total ModelUsage
}