forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
74 lines (64 loc) · 1.93 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package elasticsearch
import (
"time"
"github.com/elastic/beats/libbeat/outputs"
)
type elasticsearchConfig struct {
Protocol string `config:"protocol"`
Path string `config:"path"`
Params map[string]string `config:"parameters"`
Username string `config:"username"`
Password string `config:"password"`
ProxyURL string `config:"proxy_url"`
LoadBalance bool `config:"loadbalance"`
CompressionLevel int `config:"compression_level" validate:"min=0, max=9"`
TLS *outputs.TLSConfig `config:"ssl"`
MaxRetries int `config:"max_retries"`
Timeout time.Duration `config:"timeout"`
SaveTopology bool `config:"save_topology"`
Template Template `config:"template"`
}
type Template struct {
Enabled bool `config:"enabled"`
Name string `config:"name"`
Path string `config:"path"`
Overwrite bool `config:"overwrite"`
Versions TemplateVersions `config:"versions"`
}
type TemplateVersions struct {
Es2x TemplateVersion `config:"2x"`
}
type TemplateVersion struct {
Enabled bool `config:"enabled"`
Path string `config:"path"`
}
const (
defaultBulkSize = 50
)
var (
defaultConfig = elasticsearchConfig{
Protocol: "",
Path: "",
ProxyURL: "",
Params: nil,
Username: "",
Password: "",
Timeout: 90 * time.Second,
MaxRetries: 3,
CompressionLevel: 0,
TLS: nil,
LoadBalance: true,
Template: Template{
Enabled: true,
Versions: TemplateVersions{Es2x: TemplateVersion{Enabled: true}},
},
}
)
func (c *elasticsearchConfig) Validate() error {
if c.ProxyURL != "" {
if _, err := parseProxyURL(c.ProxyURL); err != nil {
return err
}
}
return nil
}