Merge origin/main into main
This commit is contained in:
commit
161bf5e8cb
20 changed files with 1592 additions and 116 deletions
|
|
@ -120,11 +120,15 @@ type StatusCodesByState struct {
|
|||
Pending int `json:"pending"`
|
||||
}
|
||||
|
||||
// StorageConfig configures the in-memory ring buffer and optional disk persistence.
|
||||
// StorageConfig configures the in-memory ring buffer, long-term history
|
||||
// logging, the stats database, and optional state persistence.
|
||||
type StorageConfig struct {
|
||||
HistorySize int `json:"history_size"`
|
||||
PersistenceFile string `json:"persistence_file,omitempty"`
|
||||
SaveInterval Duration `json:"save_interval,omitempty"`
|
||||
HistorySize int `json:"history_size"`
|
||||
PersistenceFile string `json:"persistence_file,omitempty"`
|
||||
SaveInterval Duration `json:"save_interval,omitempty"`
|
||||
LogsDir string `json:"logs_dir,omitempty"`
|
||||
StatsDB string `json:"stats_db,omitempty"`
|
||||
StatsRetentionDays int `json:"stats_retention_days,omitempty"`
|
||||
}
|
||||
|
||||
// DefaultsConfig provides global fallback check intervals and thresholds.
|
||||
|
|
@ -393,9 +397,12 @@ func DefaultConfig() Config {
|
|||
},
|
||||
},
|
||||
Storage: StorageConfig{
|
||||
HistorySize: 60,
|
||||
PersistenceFile: "",
|
||||
SaveInterval: NewDuration(1 * time.Minute),
|
||||
HistorySize: 60,
|
||||
PersistenceFile: "",
|
||||
SaveInterval: NewDuration(1 * time.Minute),
|
||||
LogsDir: "logs",
|
||||
StatsDB: "stats.db",
|
||||
StatsRetentionDays: 90,
|
||||
},
|
||||
Defaults: DefaultsConfig{
|
||||
Interval: NewDuration(15 * time.Second),
|
||||
|
|
@ -742,6 +749,15 @@ func (c *Config) ApplyFallbacks() {
|
|||
if c.Storage.SaveInterval <= 0 {
|
||||
c.Storage.SaveInterval = NewDuration(1 * time.Minute)
|
||||
}
|
||||
if c.Storage.LogsDir == "" {
|
||||
c.Storage.LogsDir = "logs"
|
||||
}
|
||||
if c.Storage.StatsDB == "" {
|
||||
c.Storage.StatsDB = "stats.db"
|
||||
}
|
||||
if c.Storage.StatsRetentionDays <= 0 {
|
||||
c.Storage.StatsRetentionDays = 90
|
||||
}
|
||||
|
||||
if c.Defaults.Interval <= 0 {
|
||||
c.Defaults.Interval = NewDuration(30 * time.Second)
|
||||
|
|
@ -804,6 +820,9 @@ func (c *Config) Validate() error {
|
|||
if c.Storage.SaveInterval < 0 {
|
||||
return fmt.Errorf("storage.save_interval cannot be negative")
|
||||
}
|
||||
if c.Storage.StatsRetentionDays < 0 {
|
||||
return fmt.Errorf("storage.stats_retention_days cannot be negative")
|
||||
}
|
||||
if c.Defaults.Interval < 0 {
|
||||
return fmt.Errorf("defaults.interval cannot be negative")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue