2015-12-15 22:01:03 +00:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
2015-12-23 17:46:22 +00:00
|
|
|
"errors"
|
2015-12-15 22:01:03 +00:00
|
|
|
"time"
|
2017-01-17 22:50:35 +00:00
|
|
|
|
|
|
|
"github.com/influxdata/influxdb/monitor/diagnostics"
|
2015-12-15 22:01:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2016-01-09 04:29:48 +00:00
|
|
|
// DefaultLeaseDuration is the default duration for leases.
|
|
|
|
DefaultLeaseDuration = 60 * time.Second
|
|
|
|
|
2016-12-31 01:17:59 +00:00
|
|
|
// DefaultLoggingEnabled determines if log messages are printed for the meta service.
|
2015-12-15 22:01:03 +00:00
|
|
|
DefaultLoggingEnabled = true
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config represents the meta configuration.
|
|
|
|
type Config struct {
|
2016-03-08 19:59:33 +00:00
|
|
|
Dir string `toml:"dir"`
|
2016-02-17 03:16:19 +00:00
|
|
|
|
2016-07-27 20:45:49 +00:00
|
|
|
RetentionAutoCreate bool `toml:"retention-autocreate"`
|
|
|
|
LoggingEnabled bool `toml:"logging-enabled"`
|
2015-12-15 22:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewConfig builds a new configuration with default values.
|
|
|
|
func NewConfig() *Config {
|
|
|
|
return &Config{
|
2016-07-27 20:45:49 +00:00
|
|
|
RetentionAutoCreate: true,
|
|
|
|
LoggingEnabled: DefaultLoggingEnabled,
|
2015-12-15 22:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-23 17:46:22 +00:00
|
|
|
|
2016-12-31 01:17:59 +00:00
|
|
|
// Validate returns an error if the config is invalid.
|
2015-12-23 17:46:22 +00:00
|
|
|
func (c *Config) Validate() error {
|
2016-02-02 19:10:29 +00:00
|
|
|
if c.Dir == "" {
|
2015-12-23 17:46:22 +00:00
|
|
|
return errors.New("Meta.Dir must be specified")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-01-17 22:50:35 +00:00
|
|
|
|
|
|
|
// Diagnostics returns a diagnostics representation of a subset of the Config.
|
|
|
|
func (c *Config) Diagnostics() (*diagnostics.Diagnostics, error) {
|
|
|
|
return diagnostics.RowFromMap(map[string]interface{}{
|
|
|
|
"dir": c.Dir,
|
|
|
|
}), nil
|
|
|
|
}
|