diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a126678..17e050043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ With #144 you can now join streams with differing group by dimensions. - [#145](https://github.com/influxdata/kapacitor/issues/145): The InfluxDB Out Node now writes data to InfluxDB in buffers. - [#215](https://github.com/influxdata/kapacitor/issues/215): Add performance metrics to nodes for average execution times and node throughput values. - [#144](https://github.com/influxdata/kapacitor/issues/144): Can now join streams with differing dimensions using the join.On property. +- [#155](https://github.com/influxdata/kapacitor/pull/155): Standardized config across TICK stack. ### Bugfixes diff --git a/cmd/kapacitord/run/command.go b/cmd/kapacitord/run/command.go index 8644c4d1f..b50a7bec1 100644 --- a/cmd/kapacitord/run/command.go +++ b/cmd/kapacitord/run/command.go @@ -11,7 +11,7 @@ import ( "runtime" "strconv" - "github.com/BurntSushi/toml" + cfg "github.com/influxdata/config" "github.com/influxdata/kapacitor/services/logging" ) @@ -207,7 +207,7 @@ func (cmd *Command) ParseConfig(path string) (*Config, error) { log.Printf("Using configuration at: %s\n", path) config := NewConfig() - if _, err := toml.DecodeFile(path, &config); err != nil { + if err := cfg.DecodeFile(path, &config); err != nil { return nil, err } diff --git a/cmd/kapacitord/run/config_command.go b/cmd/kapacitord/run/config_command.go index 3205ed251..bfe102e45 100644 --- a/cmd/kapacitord/run/config_command.go +++ b/cmd/kapacitord/run/config_command.go @@ -6,7 +6,7 @@ import ( "io" "os" - "github.com/BurntSushi/toml" + cfg "github.com/influxdata/config" ) // PrintConfigCommand represents the command executed by "kapacitord config". @@ -57,7 +57,7 @@ func (cmd *PrintConfigCommand) Run(args ...string) error { return fmt.Errorf("%s. To generate a valid configuration file run `kapacitord config > kapacitor.generated.conf`.", err) } - toml.NewEncoder(cmd.Stdout).Encode(config) + cfg.NewEncoder(cmd.Stdout).Encode(config) fmt.Fprint(cmd.Stdout, "\n") return nil @@ -71,7 +71,7 @@ func (cmd *PrintConfigCommand) parseConfig(path string) (*Config, error) { } config := NewConfig() - if _, err := toml.DecodeFile(path, &config); err != nil { + if err := cfg.DecodeFile(path, &config); err != nil { return nil, err } return config, nil diff --git a/cmd/kapacitord/run/config_test.go b/cmd/kapacitord/run/config_test.go index e84f37d2f..30ac2f132 100644 --- a/cmd/kapacitord/run/config_test.go +++ b/cmd/kapacitord/run/config_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/BurntSushi/toml" + "github.com/influxdata/config" "github.com/influxdata/kapacitor/cmd/kapacitord/run" ) @@ -12,7 +12,7 @@ import ( func TestConfig_Parse(t *testing.T) { // Parse configuration. var c run.Config - if _, err := toml.Decode(` + if err := config.Decode(` [replay] dir = "/tmp/replay" @@ -34,7 +34,7 @@ dir = "/tmp/task" func TestConfig_Parse_EnvOverride(t *testing.T) { // Parse configuration. var c run.Config - if _, err := toml.Decode(` + if err := config.Decode(` [replay] dir = "/tmp/replay" diff --git a/cmd/kapacitord/run/run.test b/cmd/kapacitord/run/run.test new file mode 100755 index 000000000..0b57e8b87 Binary files /dev/null and b/cmd/kapacitord/run/run.test differ diff --git a/cmd/kapacitord/run/server_test.go b/cmd/kapacitord/run/server_test.go index 7df7dbc81..bb204d848 100644 --- a/cmd/kapacitord/run/server_test.go +++ b/cmd/kapacitord/run/server_test.go @@ -18,13 +18,14 @@ import ( "testing" "time" + "github.com/influxdata/config" "github.com/influxdata/kapacitor" "github.com/influxdata/kapacitor/cmd/kapacitord/run" "github.com/influxdata/kapacitor/services/udf" + "github.com/influxdata/kapacitor/vendor/github.com/influxdb/influxdb/toml" client "github.com/influxdb/influxdb/client/v2" "github.com/influxdb/influxdb/influxql" "github.com/influxdb/influxdb/models" - "github.com/influxdb/influxdb/toml" ) func TestServer_Ping(t *testing.T) { @@ -792,7 +793,7 @@ func TestServer_UDFStreamAgents(t *testing.T) { }, config: udf.FunctionConfig{ Prog: filepath.Join(tdir, "movavg"), - Timeout: toml.Duration(time.Minute), + Timeout: config.Duration(time.Minute), }, }, // Python @@ -801,7 +802,7 @@ func TestServer_UDFStreamAgents(t *testing.T) { config: udf.FunctionConfig{ Prog: "python2", Args: []string{"-u", filepath.Join(udfDir, "agent/examples/moving_avg/moving_avg.py")}, - Timeout: toml.Duration(time.Minute), + Timeout: config.Duration(time.Minute), Env: map[string]string{ "PYTHONPATH": strings.Join( []string{filepath.Join(udfDir, "agent/py"), os.Getenv("PYTHONPATH")}, diff --git a/services/deadman/config.go b/services/deadman/config.go index 1297032e5..1cc2ee70b 100644 --- a/services/deadman/config.go +++ b/services/deadman/config.go @@ -3,12 +3,12 @@ package deadman import ( "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) const ( // Default deadman's switch interval - DefaultInterval = toml.Duration(time.Second * 10) + DefaultInterval = config.Duration(time.Second * 10) // Default deadman's switch threshold DefaultThreshold = float64(0) // Default deadman's switch id @@ -18,11 +18,11 @@ const ( ) type Config struct { - Interval toml.Duration `toml:"interval"` - Threshold float64 `toml:"threshold"` - Id string `toml:"id"` - Message string `toml:"message"` - Global bool `toml:"global"` + Interval config.Duration `toml:"interval"` + Threshold float64 `toml:"threshold"` + Id string `toml:"id"` + Message string `toml:"message"` + Global bool `toml:"global"` } func NewConfig() Config { diff --git a/services/smtp/config.go b/services/smtp/config.go index 64a4b64a6..768978e5a 100644 --- a/services/smtp/config.go +++ b/services/smtp/config.go @@ -3,7 +3,7 @@ package smtp import ( "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { @@ -21,7 +21,7 @@ type Config struct { // Default To addresses To []string `toml:"to"` // Close connection to SMTP server after idle timeout has elapsed - IdleTimeout toml.Duration `toml:"idle-timeout"` + IdleTimeout config.Duration `toml:"idle-timeout"` } func NewConfig() Config { @@ -30,6 +30,6 @@ func NewConfig() Config { Port: 25, Username: "", Password: "", - IdleTimeout: toml.Duration(time.Second * 30), + IdleTimeout: config.Duration(time.Second * 30), } } diff --git a/services/stats/config.go b/services/stats/config.go index eb09d0ba3..71237fe5a 100644 --- a/services/stats/config.go +++ b/services/stats/config.go @@ -3,24 +3,24 @@ package stats import ( "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) const ( DefaultDatabse = "_kapacitor" DefaultRetentionPolicy = "default" - DefaultStatsInterval = toml.Duration(10 * time.Second) + DefaultStatsInterval = config.Duration(10 * time.Second) DefaultTimingSampleRate = 0.10 DefaultTimingMovingAverageSize = 1000 ) type Config struct { - Enabled bool `toml:"enabled"` - StatsInterval toml.Duration `toml:"stats-interval"` - Database string `toml:"database"` - RetentionPolicy string `toml:"retention-policy"` - TimingSampleRate float64 `toml:"timing-sample-rate"` - TimingMovingAverageSize int `toml:"timing-movavg-size"` + Enabled bool `toml:"enabled"` + StatsInterval config.Duration `toml:"stats-interval"` + Database string `toml:"database"` + RetentionPolicy string `toml:"retention-policy"` + TimingSampleRate float64 `toml:"timing-sample-rate"` + TimingMovingAverageSize int `toml:"timing-movavg-size"` } func NewConfig() Config { diff --git a/services/task_store/config.go b/services/task_store/config.go index 39f5f7b2b..93d7333b0 100644 --- a/services/task_store/config.go +++ b/services/task_store/config.go @@ -4,18 +4,18 @@ import ( "fmt" "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { - Dir string `toml:"dir"` - SnapshotInterval toml.Duration `toml:"snapshot-interval"` + Dir string `toml:"dir"` + SnapshotInterval config.Duration `toml:"snapshot-interval"` } func NewConfig() Config { return Config{ Dir: "./tasks", - SnapshotInterval: toml.Duration(time.Minute), + SnapshotInterval: config.Duration(time.Minute), } } diff --git a/services/udf/config.go b/services/udf/config.go index ccf0a00f7..3824dd7ef 100644 --- a/services/udf/config.go +++ b/services/udf/config.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { @@ -14,7 +14,7 @@ type Config struct { type FunctionConfig struct { Prog string `toml:"prog"` Args []string `toml:"args"` - Timeout toml.Duration `toml:"timeout"` + Timeout config.Duration `toml:"timeout"` Env map[string]string `toml:"env"` } diff --git a/services/udp/config_test.go b/services/udp/config_test.go index a15bb3d31..f6dc115ee 100644 --- a/services/udp/config_test.go +++ b/services/udp/config_test.go @@ -3,14 +3,14 @@ package udp_test import ( "testing" - "github.com/BurntSushi/toml" + "github.com/influxdata/config" "github.com/influxdb/influxdb/services/udp" ) func TestConfig_Parse(t *testing.T) { // Parse configuration. var c udp.Config - if _, err := toml.Decode(` + if err := config.Decode(` enabled = true bind-address = ":4444" database = "awesomedb" diff --git a/udf/agent/examples/moving_avg/moving_avg.py b/udf/agent/examples/moving_avg/moving_avg.py index a30b28948..068f0fbda 100644 --- a/udf/agent/examples/moving_avg/moving_avg.py +++ b/udf/agent/examples/moving_avg/moving_avg.py @@ -1,4 +1,3 @@ - import sys import json from agent import Agent, Handler @@ -67,7 +66,6 @@ def info(self): response.info.options['size'].valueTypes.append(udf_pb2.INT) response.info.options['as'].valueTypes.append(udf_pb2.STRING) - logger.info("info") return response def init(self, init_req): diff --git a/vendor/github.com/influxdata/influxdb b/vendor/github.com/influxdata/influxdb new file mode 160000 index 000000000..903ea347d --- /dev/null +++ b/vendor/github.com/influxdata/influxdb @@ -0,0 +1 @@ +Subproject commit 903ea347df8ccc0d39151942eb028c490a2ccd51