Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateRate ¶
CalculateRate computes cost per hour between snapshot and current values. Returns the rate and whether it should be displayed.
func Cleanup ¶
func Cleanup(sessionID string)
Cleanup removes the burn rate snapshot file for a session.
func FilePath ¶
FilePath returns the path to the burn rate snapshot file for a session. Path separators are stripped from sessionID to prevent directory traversal.
func FormatRate ¶
FormatRate formats the burn rate for display.
Types ¶
type Snapshot ¶
Snapshot stores the initial cost and timestamp for rate calculation. Written to a temp file on first render, read on subsequent renders.
func LoadOrCreateSnapshot ¶
LoadOrCreateSnapshot loads an existing snapshot or creates a new one. Returns the snapshot and whether it was pre-existing.
func LoadOrCreateSnapshotAt ¶
func LoadOrCreateSnapshotAt(sessionID string, currentCost float64, now time.Time) (*Snapshot, bool, error)
LoadOrCreateSnapshotAt is the testable version that accepts a timestamp.
func LoadSnapshot ¶
LoadSnapshot reads an existing snapshot without creating one. Returns nil if no snapshot exists.