refactor(store): add error returns to all Store interface methods
Every Store method now returns an error. Callers handle errors gracefully — TUI logs to event log, server returns HTTP 500, monitor engine logs and retries. All rows.Scan() errors are now checked in sqlstore.go instead of silently appending corrupt data. - GetSites, GetAllAlerts, GetAllUsers return ([]T, error) - GetAlert returns (AlertConfig, error) instead of (AlertConfig, bool) - AddSite, UpdateSite, DeleteSite, etc. all return error - SaveCheck, LoadAllHistory, ExportData return error - ~25 caller sites updated across tui, server, monitor, main
This commit is contained in:
+14
-14
@@ -8,31 +8,31 @@ type Store interface {
|
||||
Init() error
|
||||
|
||||
// Sites
|
||||
GetSites() []models.Site
|
||||
AddSite(site models.Site)
|
||||
UpdateSite(site models.Site)
|
||||
UpdateSitePaused(id int, paused bool)
|
||||
DeleteSite(id int)
|
||||
GetSites() ([]models.Site, error)
|
||||
AddSite(site models.Site) error
|
||||
UpdateSite(site models.Site) error
|
||||
UpdateSitePaused(id int, paused bool) error
|
||||
DeleteSite(id int) error
|
||||
|
||||
// Alerts
|
||||
GetAllAlerts() []models.AlertConfig
|
||||
GetAlert(id int) (models.AlertConfig, bool)
|
||||
AddAlert(name, aType string, settings map[string]string)
|
||||
UpdateAlert(id int, name, aType string, settings map[string]string)
|
||||
DeleteAlert(id int)
|
||||
GetAllAlerts() ([]models.AlertConfig, error)
|
||||
GetAlert(id int) (models.AlertConfig, error)
|
||||
AddAlert(name, aType string, settings map[string]string) error
|
||||
UpdateAlert(id int, name, aType string, settings map[string]string) error
|
||||
DeleteAlert(id int) error
|
||||
|
||||
// Users
|
||||
GetAllUsers() []models.User
|
||||
GetAllUsers() ([]models.User, error)
|
||||
AddUser(username, publicKey, role string) error
|
||||
UpdateUser(id int, username, publicKey, role string) error
|
||||
DeleteUser(id int) error
|
||||
|
||||
// History
|
||||
SaveCheck(siteID int, latencyNs int64, isUp bool)
|
||||
LoadAllHistory(limit int) map[int][]models.CheckRecord
|
||||
SaveCheck(siteID int, latencyNs int64, isUp bool) error
|
||||
LoadAllHistory(limit int) (map[int][]models.CheckRecord, error)
|
||||
|
||||
// Backup & Restore
|
||||
ExportData() models.Backup
|
||||
ExportData() (models.Backup, error)
|
||||
ImportData(data models.Backup) error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user