forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
48 lines (39 loc) · 1.65 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package tsdb
import (
"time"
"github.com/influxdb/influxdb/toml"
)
const (
// DefaultRetentionAutoCreate is the default for auto-creating retention policies
DefaultRetentionAutoCreate = true
// DefaultRetentionCheckEnabled is the default for checking for retention policy enforcement
DefaultRetentionCheckEnabled = true
// DefaultRetentionCreatePeriod represents how often the server will check to see if new
// shard groups need to be created in advance for writing
DefaultRetentionCreatePeriod = 45 * time.Minute
// DefaultRetentionCheckPeriod is the period of time between retention policy checks are run
DefaultRetentionCheckPeriod = 10 * time.Minute
)
type Config struct {
Dir string `toml:"dir"`
RetentionAutoCreate bool `toml:"retention-auto-create"`
RetentionCheckEnabled bool `toml:"retention-check-enabled"`
RetentionCheckPeriod toml.Duration `toml:"retention-check-period"`
RetentionCreatePeriod toml.Duration `toml:"retention-create-period"`
}
func NewConfig() Config {
return Config{
RetentionAutoCreate: DefaultRetentionAutoCreate,
RetentionCheckEnabled: DefaultRetentionCheckEnabled,
RetentionCheckPeriod: toml.Duration(DefaultRetentionCheckPeriod),
RetentionCreatePeriod: toml.Duration(DefaultRetentionCreatePeriod),
}
}
// ShardGroupPreCreateCheckPeriod returns the check interval to pre-create shard groups.
// If it was not defined in the config, it defaults to DefaultShardGroupPreCreatePeriod
func (c *Config) ShardGroupPreCreateCheckPeriod() time.Duration {
if c.RetentionCreatePeriod != 0 {
return time.Duration(c.RetentionCreatePeriod)
}
return DefaultRetentionCreatePeriod
}