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 ¶
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 ¶
NewSQLiteStore initializes a new sqliteStore with optional encryption support.
Click to show internal directories.
Click to hide internal directories.