From e294db3c49351cfb389a39f5d34e8d3659f4cb4c Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Wed, 10 Jun 2015 20:41:32 -0700 Subject: [PATCH 1/2] Set openTSDB defaults in service --- services/opentsdb/config.go | 19 +++++++++++++++++++ services/opentsdb/service.go | 11 +++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/services/opentsdb/config.go b/services/opentsdb/config.go index 324002b720..0e0ddf0f7c 100644 --- a/services/opentsdb/config.go +++ b/services/opentsdb/config.go @@ -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 +} diff --git a/services/opentsdb/service.go b/services/opentsdb/service.go index cdaecd20fa..f774ce1976 100644 --- a/services/opentsdb/service.go +++ b/services/opentsdb/service.go @@ -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), } From 90a42f9c4d7debcedb33dd663affc27f117b9046 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Wed, 10 Jun 2015 20:43:23 -0700 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1073c90ef..354516b4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]