Documentation
¶
Index ¶
- type KVRecord
- type KVStore
- func (kv *KVStore) Delete(key Key) error
- func (kv *KVStore) DeleteInt(key KeyInt) error
- func (kv *KVStore) DeleteRaw(keyStr string) error
- func (kv *KVStore) EnsureSystemDefaults() error
- func (kv *KVStore) ExistsRaw(keyStr string) bool
- func (kv *KVStore) Get(key Key) (string, error)
- func (kv *KVStore) GetAll() ([]*KVRecord, error)
- func (kv *KVStore) GetDisplayName() string
- func (kv *KVStore) GetInt(key KeyInt) (int, error)
- func (kv *KVStore) GetIntWithDefault(key KeyInt, defaultValue int) int
- func (kv *KVStore) GetRaw(keyStr string) (string, error)
- func (kv *KVStore) GetWithDefault(key Key, defaultValue string) string
- func (kv *KVStore) Initialize() error
- func (kv *KVStore) RequiredInt(key KeyInt) int
- func (kv *KVStore) Set(key Key, value string) error
- func (kv *KVStore) SetInt(key KeyInt, value int) error
- func (kv *KVStore) SetRaw(keyStr, value string) error
- type Key
- type KeyInt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KVRecord ¶
type KVRecord struct {
Key string `db:"key"`
Value string `db:"value"`
UpdatedAt string `db:"updated_at"`
}
KVRecord represents a key-value record in the database
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore provides a key-value configuration store with caching
func (*KVStore) DeleteInt ¶
DeleteInt removes an integer key-value pair from database and int cache only
func (*KVStore) EnsureSystemDefaults ¶
EnsureSystemDefaults ensures all required system parameters exist with sensible defaults This should be called during Initialize() to populate missing system parameters
func (*KVStore) GetDisplayName ¶
GetDisplayName returns the system display name or hostname if empty
func (*KVStore) GetIntWithDefault ¶
GetIntWithDefault retrieves an integer value by key, returning default if not found
func (*KVStore) GetRaw ¶
GetRaw retrieves a value by raw key string from appropriate cache or database
func (*KVStore) GetWithDefault ¶
GetWithDefault retrieves a value by key, returning default if not found
func (*KVStore) Initialize ¶
Initialize loads the initial cache from database and sets up system defaults This should be called after database migrations are complete
func (*KVStore) RequiredInt ¶
RequiredInt returns the value of a required integer system parameter. Parameters are seeded by EnsureSystemDefaults, so a miss means the kvstore row was deleted or corrupted; rather than crashing the daemon (this is called from long-running paths like health checks), it logs loudly and falls back to the registered default.
type Key ¶
type Key string
Key represents a strongly-typed configuration key for string values
const ( // System display name (empty = use hostname) KeySystemDisplayName Key = "system.display.name.str" )
String configuration keys - users must use these constants
type KeyInt ¶
type KeyInt string
KeyInt represents a strongly-typed configuration key for integer values
const ( // Health check thresholds KeyHealthDegradedThreshold KeyInt = "health.degraded_threshold.int" KeyHealthRestoredThreshold KeyInt = "health.restored_threshold.int" // Disk space thresholds KeyDiskSpaceThresholdBytes KeyInt = "health.disk_space_threshold_bytes.int" // CPU load thresholds (stored as percentage 0-100) KeyCPULoadThresholdPercent KeyInt = "health.cpu_load_threshold_percent.int" // Health check intervals KeyHealthCheckIntervalSec KeyInt = "health.check_interval_sec.int" // Debug settings KeyHealthDebugFail KeyInt = "health.debug_fail.int" // When non-zero, forces health checks to fail // Cron debug settings KeyCronDebugTickerInterval KeyInt = "cron.debug_ticker_interval.int" // Override cron ticker interval in seconds (0 = use default 60s) KeyCronDebugForceRun KeyInt = "cron.debug_force_run.int" // When 1, get all plans and force probability to 1.0 // Backup debug settings KeyBackupDebugTimeMachine KeyInt = "backup.debug_time_machine.int" // When 1, enables debug endpoint to time-shift backups )
Integer configuration keys - users must use these constants