stores

package
v0.0.0-...-4c003e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stores keeps module state in OhMyServer's shared database for modules that keep it in files when they run on their own. Each type implements an interface the module defines; tables are named after the module they belong to (docs/module-contract.md, Storage).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string) (*sql.DB, error)

Open opens the shared database: WAL journaling so readers never block the writer, a busy timeout for concurrent writers, foreign keys, and immediate transactions so a transaction never fails upgrading its lock.

Types

type DHCP

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

DHCP keeps the DHCP server's settings, reservations and leases in the shared database (dhcp-go keeps them in YAML files when it runs on its own). The tables are the ones dhcp-go's own SQLite store created, so existing state carries over.

func NewDHCP

func NewDHCP(ctx context.Context, db *sql.DB) (*DHCP, error)

NewDHCP migrates the dhcp_ tables in db.

func (*DHCP) Config

func (s *DHCP) Config(ctx context.Context) (cfg server.Config, ok bool, err error)

Config returns the saved configuration; ok is false before the first save.

func (*DHCP) CreateReservation

func (s *DHCP) CreateReservation(ctx context.Context, r *server.Reservation) error

CreateReservation inserts r and sets its ID and timestamps.

func (*DHCP) DeleteLease

func (s *DHCP) DeleteLease(ip string) error

DeleteLease implements server.LeaseStore.

func (*DHCP) DeleteReservation

func (s *DHCP) DeleteReservation(ctx context.Context, id int64) error

DeleteReservation removes a reservation; removing a missing one succeeds.

func (*DHCP) Leases

func (s *DHCP) Leases(ctx context.Context) ([]server.Lease, error)

Leases returns every stored lease.

func (*DHCP) PruneLeases

func (s *DHCP) PruneLeases(ctx context.Context, t time.Time) error

PruneLeases deletes leases that expired before t.

func (*DHCP) Reservation

func (s *DHCP) Reservation(ctx context.Context, id int64) (server.Reservation, error)

Reservation returns one reservation.

func (*DHCP) Reservations

func (s *DHCP) Reservations(ctx context.Context) ([]server.Reservation, error)

Reservations returns every reservation.

func (*DHCP) SaveConfig

func (s *DHCP) SaveConfig(ctx context.Context, cfg server.Config) error

SaveConfig stores the configuration.

func (*DHCP) SaveLease

func (s *DHCP) SaveLease(l server.Lease) error

SaveLease implements server.LeaseStore.

func (*DHCP) UpdateReservation

func (s *DHCP) UpdateReservation(ctx context.Context, r *server.Reservation) error

UpdateReservation replaces r's fields.

type DockerApps

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

DockerApps keeps docker-go's install records (apps.Store).

func NewDockerApps

func NewDockerApps(ctx context.Context, db *sql.DB) (*DockerApps, error)

NewDockerApps migrates the docker_ tables and returns the store.

func (*DockerApps) DeleteApp

func (s *DockerApps) DeleteApp(ctx context.Context, id string) error

func (*DockerApps) GetApp

func (s *DockerApps) GetApp(ctx context.Context, id string) (*apps.Record, error)

func (*DockerApps) ListApps

func (s *DockerApps) ListApps(ctx context.Context) ([]apps.Record, error)

func (*DockerApps) PutApp

func (s *DockerApps) PutApp(ctx context.Context, r apps.Record) error

type ForwardRules

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

ForwardRules keeps the port forwarder's rules in the shared database (forward-go keeps them in a YAML file when it runs on its own). The table is the one forward-go's own SQLite store created, so existing rules carry over.

func NewForwardRules

func NewForwardRules(ctx context.Context, db *sql.DB) (*ForwardRules, error)

NewForwardRules migrates the forward_ tables in db.

func (*ForwardRules) Create

func (s *ForwardRules) Create(ctx context.Context, r *forward.Rule) error

Create inserts r and sets its ID and timestamps.

func (*ForwardRules) Delete

func (s *ForwardRules) Delete(ctx context.Context, id int64) error

Delete removes a rule; removing a missing rule succeeds.

func (*ForwardRules) Get

func (s *ForwardRules) Get(ctx context.Context, id int64) (forward.Rule, error)

Get returns one rule.

func (*ForwardRules) List

func (s *ForwardRules) List(ctx context.Context) ([]forward.Rule, error)

List returns every rule by name.

func (*ForwardRules) Update

func (s *ForwardRules) Update(ctx context.Context, r *forward.Rule) error

Update replaces r's fields, keeping its creation time.

type GatewayConfig

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

GatewayConfig keeps the yabber gateway's configuration, which yabber keeps in a YAML file when it runs on its own.

func NewGatewayConfig

func NewGatewayConfig(ctx context.Context, db *sql.DB) (*GatewayConfig, error)

NewGatewayConfig migrates the yabber_ tables and returns the store.

func (*GatewayConfig) Load

func (s *GatewayConfig) Load(ctx context.Context) (config yabber.Config, ok bool, err error)

Load returns the saved configuration, or ok=false if none was saved yet.

func (*GatewayConfig) Save

func (s *GatewayConfig) Save(config yabber.Config) error

Save stores config; it matches yabber/api.Options.Save.

Jump to

Keyboard shortcuts

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