forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
42 lines (37 loc) · 1.15 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
package influxdb
import (
"net/url"
"time"
"github.com/influxdata/kapacitor/services/udp"
)
type Config struct {
Enabled bool `toml:"enabled"`
URLs []string `toml:"urls"`
Username string `toml:"username"`
Password string `toml:"password"`
Timeout time.Duration `toml:"timeout"`
Subscriptions map[string][]string `toml:"subscriptions"`
ExcludedSubscriptions map[string][]string `toml:"excluded-subscriptions"`
UDPBuffer int `toml:"udp-buffer"`
UDPReadBuffer int `toml:"udp-read-buffer"`
}
func NewConfig() Config {
return Config{
Enabled: true,
URLs: []string{"http://localhost:8086"},
Username: "",
Password: "",
Subscriptions: make(map[string][]string),
ExcludedSubscriptions: make(map[string][]string),
UDPBuffer: udp.DefaultBuffer,
}
}
func (c Config) Validate() error {
for _, u := range c.URLs {
_, err := url.Parse(u)
if err != nil {
return err
}
}
return nil
}