diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:40:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:40:59 +0000 |
commit | bc4e624732bd51c0dd1e9529cf228e8c23127732 (patch) | |
tree | d95dab8960e9d02d3b95f8653074ad2e54ca207c /pkg/config/history_retention.go | |
parent | Initial commit. (diff) | |
download | icingadb-bc4e624732bd51c0dd1e9529cf228e8c23127732.tar.xz icingadb-bc4e624732bd51c0dd1e9529cf228e8c23127732.zip |
Adding upstream version 1.1.1.upstream/1.1.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pkg/config/history_retention.go')
-rw-r--r-- | pkg/config/history_retention.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/config/history_retention.go b/pkg/config/history_retention.go new file mode 100644 index 0000000..d4373b7 --- /dev/null +++ b/pkg/config/history_retention.go @@ -0,0 +1,30 @@ +package config + +import ( + "github.com/icinga/icingadb/pkg/icingadb/history" + "github.com/pkg/errors" + "time" +) + +// Retention defines configuration for history retention. +type Retention struct { + HistoryDays uint64 `yaml:"history-days"` + SlaDays uint64 `yaml:"sla-days"` + Interval time.Duration `yaml:"interval" default:"1h"` + Count uint64 `yaml:"count" default:"5000"` + Options history.RetentionOptions `yaml:"options"` +} + +// Validate checks constraints in the supplied retention configuration and +// returns an error if they are violated. +func (r *Retention) Validate() error { + if r.Interval <= 0 { + return errors.New("retention interval must be positive") + } + + if r.Count == 0 { + return errors.New("count must be greater than zero") + } + + return r.Options.Validate() +} |