-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
54 lines (50 loc) · 1.05 KB
/
options.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
package avchecker
import (
"github.com/claudetech/loggo"
"github.com/claudetech/loggo/default"
"io"
"net/http"
"time"
)
type miniHttpClient interface {
Do(*http.Request) (*http.Response, error)
}
type Options struct {
CheckInterval time.Duration
PublishInterval time.Duration
Logger *loggo.Logger
Formatter Formatter
HttpClient miniHttpClient
RequestType string
RequestBody io.Reader
RequestHeaders map[string]string
ExtraFields map[string]string
FatalThreshold float64
totalRuns int
}
func (o *Options) setDefaults() {
if o.CheckInterval == 0 {
o.CheckInterval = 10 * time.Second
}
if o.PublishInterval == 0 {
o.PublishInterval = 1 * time.Minute
}
if o.Logger == nil {
o.Logger = loggo_default.Log
}
if o.Formatter == nil {
o.Formatter = &JsonFormatter{}
}
if o.ExtraFields == nil {
o.ExtraFields = make(map[string]string)
}
if o.HttpClient == nil {
o.HttpClient = http.DefaultClient
}
if o.RequestType == "" {
o.RequestType = "GET"
}
if o.totalRuns == 0 {
o.totalRuns = -1
}
}