storage

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 5 Imported by: 0

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

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

func Open(path string) (*Store, error)

Open opens (creating if needed) the SQLite database at path and applies the schema and connection pragmas.

func (*Store) Apps

func (s *Store) Apps(since, until time.Time) ([]types.AppTraffic, error)

Apps returns per-app totals over [since, until), ranked by total bytes.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database.

func (*Store) Domains

func (s *Store) Domains(since, until time.Time) ([]types.DomainStat, error)

Domains returns per-domain totals over [since, until), ranked by total bytes.

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

func (s *Store) Purge(before time.Time) error

Purge deletes samples older than before, for retention management.

func (*Store) TimeSeries

func (s *Store) TimeSeries(since, until time.Time, step time.Duration) ([]types.TimePoint, error)

TimeSeries returns rx/tx totals bucketed into intervals of step over [since, until). Empty intervals are omitted.

Jump to

Keyboard shortcuts

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