Documentation
¶
Overview ¶
Package storage persists aggregated traffic into SQLite and answers the ranking / time-series queries the API exposes. It uses the pure-Go modernc.org/sqlite driver so the binary needs no system SQLite.
Index ¶
- type Store
- func (s *Store) AppTimeSeries(app string, since, until time.Time, step time.Duration) ([]types.TimePoint, error)
- func (s *Store) Apps(since, until time.Time) ([]types.AppTraffic, error)
- func (s *Store) Checkpoint()
- func (s *Store) Close() error
- func (s *Store) Domains(since, until time.Time) ([]types.DomainStat, error)
- func (s *Store) DomainsForApp(app string, since, until time.Time) ([]types.DomainStat, error)
- func (s *Store) EnforceSizeCap(maxBytes int64) (bool, error)
- func (s *Store) FlushApps(bucket int64, apps []types.AppTraffic) error
- func (s *Store) FlushDomains(bucket int64, domains []types.DomainStat) error
- func (s *Store) Purge(before time.Time) (bool, error)
- func (s *Store) SizeOnDisk() int64
- func (s *Store) TimeSeries(since, until time.Time, step time.Duration) ([]types.TimePoint, error)
- func (s *Store) Vacuum() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a handle to the netscope database.
func Open ¶
Open opens (creating if needed) the SQLite database at path and applies the schema and connection pragmas.
func (*Store) AppTimeSeries ¶ added in v0.5.0
func (s *Store) AppTimeSeries(app string, since, until time.Time, step time.Duration) ([]types.TimePoint, error)
AppTimeSeries returns one app's rx/tx bucketed into intervals of step over [since, until). Empty intervals are omitted.
func (*Store) Checkpoint ¶ added in v0.5.0
func (s *Store) Checkpoint()
Checkpoint flushes the WAL back into the main database and truncates it, so the WAL file can't grow without bound. Best-effort.
func (*Store) Domains ¶
Domains returns per-domain totals over [since, until), ranked by total bytes.
func (*Store) DomainsForApp ¶ added in v0.5.0
DomainsForApp returns per-domain totals for a single app over [since, until), ranked by total bytes — backs the dashboard's per-app drill-down.
func (*Store) EnforceSizeCap ¶ added in v0.5.0
EnforceSizeCap is the disk safety net: independent of time-based retention, it drops the oldest data (a day at a time) until the database fits under maxBytes. It checkpoints + vacuums between steps so on-disk size reflects each deletion. Returns whether anything was removed. A non-positive cap disables it.
func (*Store) FlushApps ¶
func (s *Store) FlushApps(bucket int64, apps []types.AppTraffic) error
FlushApps adds the per-app counters for the given bucket. Repeated flushes to the same bucket accumulate rather than overwrite.
func (*Store) FlushDomains ¶
func (s *Store) FlushDomains(bucket int64, domains []types.DomainStat) error
FlushDomains adds the per-domain counters for the given bucket.
func (*Store) Purge ¶
Purge deletes samples older than before, for retention management. It reports whether any rows were actually removed (so the caller can decide to VACUUM).
func (*Store) SizeOnDisk ¶ added in v0.5.0
SizeOnDisk returns the total bytes the database occupies, including the WAL and shared-memory side files (which can dominate between checkpoints).
func (*Store) TimeSeries ¶
TimeSeries returns rx/tx totals bucketed into intervals of step over [since, until). Empty intervals are omitted.