db

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoName

func AutoName(kind string, t time.Time) string

AutoName builds a default run name from kind + timestamp.

func FormatWhen

func FormatWhen(t time.Time) string

FormatWhen renders a short local date/time for history rows.

Types

type Averages added in v1.4.0

type Averages struct {
	Count        int
	DownloadMbps float64
	UploadMbps   float64
	PingMs       float64
}

Averages holds the mean download/upload/ping across saved runs of a kind.

type Store

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

Store is a thin SQLite wrapper for settings + saved test runs.

func Open

func Open() (*Store, error)

Open creates (if needed) and opens riptide.db under the user config dir. Path: <UserConfigDir>/riptide/riptide.db

func OpenPath

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

OpenPath opens a specific database file (used by tests and Open).

func (*Store) Averages added in v1.4.0

func (s *Store) Averages(kind string) (Averages, error)

Averages returns the mean download, upload, and ping over all saved runs of the given kind (empty kind defaults to "speed"). Zero rows yields a Count of 0.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database.

func (*Store) CountRuns

func (s *Store) CountRuns() (int, error)

CountRuns returns total saved runs.

func (*Store) GetSetting

func (s *Store) GetSetting(key, def string) string

GetSetting reads a setting value; missing keys return def.

func (*Store) LatestRuns

func (s *Store) LatestRuns(n int) ([]TestRun, error)

LatestRuns returns the most recent n test runs (newest first).

func (*Store) Path

func (s *Store) Path() string

Path returns the on-disk database path.

func (*Store) Reset

func (s *Store) Reset(wipeSettings bool) error

Reset clears all test runs and optional settings keys (theme is kept unless wipeSettings).

func (*Store) SaveTestRun

func (s *Store) SaveTestRun(r TestRun) (int64, error)

SaveTestRun inserts a named run and returns its id.

func (*Store) SetSetting

func (s *Store) SetSetting(key, value string) error

SetSetting writes a setting value.

type TestRun

type TestRun struct {
	ID           int64
	Name         string
	Kind         string // "speed" | "bandwidth"
	DownloadMbps float64
	UploadMbps   float64
	PingMs       float64
	DownloadPeak float64
	UploadPeak   float64
	Server       string
	CreatedAt    time.Time
}

TestRun is one saved speed/bandwidth snapshot.

Jump to

Keyboard shortcuts

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