mirror of
https://github.com/mostlygeek/llama-swap.git
synced 2026-06-09 06:46:34 +02:00
a4b91e08cf
- update README.md with new docker instructions - update docs/configuration.md - update .github/workflows to have pinned action versions - gofmt events package - fix small bugs in CI scripts - reduce config options for internal/perf/monitor and config. A ring buffer is used to keep 1hr of entries at max 5s granularity. For long term stats use prometheus monitoring on /metrics Fixes #744
35 lines
781 B
Go
35 lines
781 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// PerformanceConfig holds configuration for system performance monitoring
|
|
type PerformanceConfig struct {
|
|
Disabled bool `yaml:"disabled"`
|
|
Every time.Duration `yaml:"every"`
|
|
}
|
|
|
|
func (p *PerformanceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
type rawPerformanceConfig PerformanceConfig
|
|
defaults := rawPerformanceConfig{
|
|
Every: 5 * time.Second,
|
|
}
|
|
|
|
if err := unmarshal(&defaults); err != nil {
|
|
return err
|
|
}
|
|
|
|
*p = PerformanceConfig(defaults)
|
|
return nil
|
|
}
|
|
|
|
// Validate checks the PerformanceConfig values and returns an error if invalid
|
|
func (p *PerformanceConfig) Validate() error {
|
|
if p.Every < 5*time.Second {
|
|
return fmt.Errorf("every must be at least 5s, got %v", p.Every)
|
|
}
|
|
return nil
|
|
}
|