Merge pull request #2900 from influxdb/fix_opentsdb_defaults
Set openTSDB defaults in servicepull/2886/head
commit
6e41c1f2da
|
@ -8,6 +8,7 @@
|
|||
- [#2897](https://github.com/influxdb/influxdb/pull/2897): Ensure target Graphite database exists
|
||||
- [#2898](https://github.com/influxdb/influxdb/pull/2898): Ensure target openTSDB database exists
|
||||
- [#2895](https://github.com/influxdb/influxdb/pull/2895): Use Graphite input defaults where necessary
|
||||
- [#2900](https://github.com/influxdb/influxdb/pull/2900): Use openTSDB input defaults where necessary
|
||||
|
||||
## v0.9.0-rc33 [2015-06-09]
|
||||
|
||||
|
|
|
@ -30,3 +30,22 @@ func NewConfig() Config {
|
|||
ConsistencyLevel: DefaultConsistencyLevel,
|
||||
}
|
||||
}
|
||||
|
||||
// WithDefaults takes the given config and returns a new config with any required
|
||||
// default values set.
|
||||
func (c *Config) WithDefaults() *Config {
|
||||
d := *c
|
||||
if d.BindAddress == "" {
|
||||
d.BindAddress = DefaultBindAddress
|
||||
}
|
||||
if d.Database == "" {
|
||||
d.Database = DefaultDatabase
|
||||
}
|
||||
if d.RetentionPolicy == "" {
|
||||
d.RetentionPolicy = DefaultRetentionPolicy
|
||||
}
|
||||
if d.ConsistencyLevel == "" {
|
||||
d.ConsistencyLevel = DefaultConsistencyLevel
|
||||
}
|
||||
return &d
|
||||
}
|
||||
|
|
|
@ -44,16 +44,19 @@ type Service struct {
|
|||
|
||||
// NewService returns a new instance of Service.
|
||||
func NewService(c Config) (*Service, error) {
|
||||
consistencyLevel, err := cluster.ParseConsistencyLevel(c.ConsistencyLevel)
|
||||
// Use defaults where necessary.
|
||||
d := c.WithDefaults()
|
||||
|
||||
consistencyLevel, err := cluster.ParseConsistencyLevel(d.ConsistencyLevel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &Service{
|
||||
err: make(chan error),
|
||||
BindAddress: c.BindAddress,
|
||||
Database: c.Database,
|
||||
RetentionPolicy: c.RetentionPolicy,
|
||||
BindAddress: d.BindAddress,
|
||||
Database: d.Database,
|
||||
RetentionPolicy: d.RetentionPolicy,
|
||||
ConsistencyLevel: consistencyLevel,
|
||||
Logger: log.New(os.Stderr, "[opentsdb] ", log.LstdFlags),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue