forked from premendrasingh/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
57 lines (48 loc) · 1.35 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package redis
import (
"errors"
"fmt"
"time"
"github.com/elastic/beats/libbeat/outputs"
"github.com/elastic/beats/libbeat/outputs/transport"
)
type redisConfig struct {
Password string `config:"password"`
Index string `config:"index"`
Port int `config:"port"`
LoadBalance bool `config:"loadbalance"`
Timeout time.Duration `config:"timeout"`
MaxRetries int `config:"max_retries"`
TLS *outputs.TLSConfig `config:"tls"`
Proxy transport.ProxyConfig `config:",inline"`
Db int `config:"db"`
DataType string `config:"datatype"`
HostTopology string `config:"host_topology"`
PasswordTopology string `config:"password_topology"`
DbTopology int `config:"db_topology"`
}
var (
defaultConfig = redisConfig{
Port: 6379,
LoadBalance: true,
Timeout: 5 * time.Second,
MaxRetries: 3,
TLS: nil,
Db: 0,
DataType: "list",
HostTopology: "",
PasswordTopology: "",
DbTopology: 1,
}
)
func (c *redisConfig) Validate() error {
switch c.DataType {
case "", "list", "channel":
default:
return fmt.Errorf("redis data type %v not supported", c.DataType)
}
if c.Index == "" {
return errors.New("index required")
}
return nil
}