database

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 17 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

Index

Constants

View Source
const (
	AdminUser = "admin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store interface {
	// Init executes the initial schema setup.
	Init() error
	// Close terminates the database connection.
	Close() error
	// Create persists a new switch and returns the created record. Uses sw.UserId for ownership.
	Create(sw api.Switch) (api.Switch, error)
	// DecryptSwitch decrypts sensitive content.
	DecryptSwitch(*api.Switch) error
	// Delete removes a switch record from the store, scoped to the given user.
	Delete(userID string, id int) error
	// EncryptSwitch encrypts sensitive content.
	EncryptSwitch(*api.Switch) error
	// GetAll retrieves a list of switches up to the specified limit, scoped to the given user.
	GetAll(userID string, limit int) ([]api.Switch, error)
	// GetByID retrieves a single switch by its unique identifier, scoped to the given user.
	GetByID(userID string, id int) (api.Switch, error)
	// GetEligibleReminders retrieves switches that are approaching expiry but haven't had a reminder sent yet.
	GetEligibleReminders(limit int) ([]api.Switch, error)
	// GetExpired retrieves switches whose trigger_at time has passed but haven't been sent.
	GetExpired(limit int) ([]api.Switch, error)
	// Ping verifies the database connection is alive.
	Ping() error
	// Update updates an existing switch. Uses sw.UserId for ownership scoping.
	Update(id int, sw api.Switch) (api.Switch, error)
}

Store defines the behaviors required for persisting and managing dead man switches.

func NewInMemorySQLiteStore

func NewInMemorySQLiteStore() (Store, error)

NewInMemorySQLiteStore initializes an in-memory SQLite store suitable for demo mode. No data is persisted to disk and a random encryption key is generated.

func NewSQLiteStore

func NewSQLiteStore(dbPath string) (Store, error)

NewSQLiteStore initializes a new sqliteStore with optional encryption support.

Jump to

Keyboard shortcuts

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