historian

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package historian turns silk's live-only tag trends into reviewable history: it records core.Tag changes into a SQLite table and answers time-range queries, so a screen that only shows the current value can be backed by a scrollable, persisted trend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Historian

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

Historian owns a SQLite handle holding a single samples table.

func NewHistorian

func NewHistorian(dbPath string) (*Historian, error)

NewHistorian opens (creating if needed) the SQLite database at dbPath and makes sure the samples table and its (tag, ts) index exist.

func (*Historian) Close

func (h *Historian) Close() error

Close releases the underlying database handle.

func (*Historian) Query

func (h *Historian) Query(tag string, from, to time.Time) ([]Sample, error)

Query returns tag's samples whose timestamp is in [from, to] inclusive, ordered by timestamp ascending.

func (*Historian) Record

func (h *Historian) Record(tags *core.TagDB, names []string) func()

Record subscribes to each named tag and writes one row per change; the returned func unsubscribes them all. Subscribe primes each callback with the tag's current value, so recording opens with a sample of the tag's state at record-start, followed by one per subsequent change.

type Sample

type Sample struct {
	TS    time.Time
	Value float64
}

Sample is one recorded point: its wall-clock time and float value.

Jump to

Keyboard shortcuts

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