store

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyBalance added in v0.6.0

type DailyBalance struct {
	Platform string
	Currency string
	Day      string // "YYYY-MM-DD" (UTC)
	Balance  float64
}

type Deployment

type Deployment struct {
	Slug        string  `json:"slug"`
	ContainerID string  `json:"containerId"`
	Name        string  `json:"name"`
	Image       string  `json:"image"`
	Status      string  `json:"status"`
	Runtime     string  `json:"runtime"`
	CPUPercent  float64 `json:"cpuPercent"`
	MemoryMB    float64 `json:"memoryMb"`
	CreatedAt   string  `json:"createdAt"`
	UpdatedAt   string  `json:"updatedAt"`
}

type EarningsRecord

type EarningsRecord struct {
	Platform  string  `json:"platform"`
	Balance   float64 `json:"balance"`
	Currency  string  `json:"currency"`
	Error     string  `json:"error,omitempty"`
	CreatedAt string  `json:"createdAt"`
}

type FleetDevice added in v0.6.0

type FleetDevice struct {
	ID        int64    `json:"id"`
	Name      string   `json:"name"`
	Kind      string   `json:"kind"`
	Endpoint  string   `json:"endpoint"`
	OS        string   `json:"os"`
	Arch      string   `json:"arch"`
	Status    string   `json:"status"`
	Services  []string `json:"services"`
	LastSeen  string   `json:"lastSeen"`
	CreatedAt string   `json:"createdAt"`
}

type Store

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

func Open

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

func (*Store) Close

func (s *Store) Close() error

func (*Store) DeleteDeployment

func (s *Store) DeleteDeployment(slug string) error

func (*Store) DeleteFleetDevice added in v0.6.0

func (s *Store) DeleteFleetDevice(id int64) error

func (*Store) GetCredentials

func (s *Store) GetCredentials(slug string) (map[string]string, error)

func (*Store) GetDeployment

func (s *Store) GetDeployment(slug string) (Deployment, bool, error)

func (*Store) ListCredentialSlugs added in v0.7.0

func (s *Store) ListCredentialSlugs() []string

ListCredentialSlugs returns the slug of every service that has saved credentials, ordered by slug. collectAll unions this with the deployment set so imageless supported services (which never create a deployment row) still participate in the scheduled collection cycle.

func (*Store) ListDailyBalances added in v0.6.0

func (s *Store) ListDailyBalances(daysBack int) []DailyBalance

ListDailyBalances returns the latest successful balance (rows whose error column is empty) for each (platform, day) over the last daysBack days. The latest row per (platform, day) is chosen by MAX(id), not MAX(created_at): created_at is stored as RFC3339Nano whose variable-length fraction makes a lexicographic MAX(created_at) mis-order same-second rows (e.g. "…:00Z" sorts AFTER "…:00.5Z" because 'Z' > '.'), so the monotonic AUTOINCREMENT id is the deterministic "last written wins" key.

func (*Store) ListDeployments

func (s *Store) ListDeployments() []Deployment

func (*Store) ListFleetDevices added in v0.6.0

func (s *Store) ListFleetDevices() []FleetDevice

func (*Store) ListLatestEarnings

func (s *Store) ListLatestEarnings() []EarningsRecord

ListLatestEarnings returns the most recently written row per platform, INCLUDING error rows (the dashboard breakdown and notifications rely on the latest row even when it failed). The latest row per platform is chosen by MAX(id), not MAX(created_at): created_at is RFC3339Nano whose variable-length fraction makes a lexicographic MAX(created_at) mis-order same-second rows (e.g. "…:00Z" sorts ABOVE "…:00.5Z" because 'Z' > '.'), so the monotonic AUTOINCREMENT id is the deterministic "last written wins" key — matching the shape ListDailyBalances already uses.

func (*Store) RecordEvent

func (s *Store) RecordEvent(slug, event, detail string)

func (*Store) SaveCredentials

func (s *Store) SaveCredentials(slug string, values map[string]string) error

func (*Store) SaveEarnings

func (s *Store) SaveEarnings(record EarningsRecord) (EarningsRecord, error)

func (*Store) UpsertDeployment

func (s *Store) UpsertDeployment(dep Deployment) error

func (*Store) UpsertFleetDevice added in v0.6.0

func (s *Store) UpsertFleetDevice(device FleetDevice) (FleetDevice, error)

func (*Store) UpsertFleetHeartbeat added in v0.6.0

func (s *Store) UpsertFleetHeartbeat(device FleetDevice) (FleetDevice, error)

Jump to

Keyboard shortcuts

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