forked from raboof/beats-output-http
/
config.go
63 lines (56 loc) · 1.7 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
package http
import (
"time"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
)
type httpConfig 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"`
BatchPublish bool `config:"batch_publish"`
BatchSize int `config:"batch_size"`
CompressionLevel int `config:"compression_level" validate:"min=0, max=9"`
TLS *tlscommon.Config `config:"tls"`
MaxRetries int `config:"max_retries"`
Timeout time.Duration `config:"timeout"`
Headers map[string]string `config:"headers"`
ContentType string `config:"content_type"`
Backoff backoff `config:"backoff"`
}
type backoff struct {
Init time.Duration
Max time.Duration
}
var (
defaultConfig = httpConfig{
Protocol: "",
Path: "",
Params: nil,
ProxyURL: "",
Username: "",
Password: "",
BatchPublish: false,
BatchSize: 2048,
Timeout: 90 * time.Second,
CompressionLevel: 0,
TLS: nil,
MaxRetries: 3,
LoadBalance: false,
Backoff: backoff{
Init: 1 * time.Second,
Max: 60 * time.Second,
},
}
)
func (c *httpConfig) Validate() error {
if c.ProxyURL != "" {
if _, err := parseProxyURL(c.ProxyURL); err != nil {
return err
}
}
return nil
}