-
Notifications
You must be signed in to change notification settings - Fork 4
/
options.go
67 lines (58 loc) · 1.24 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
55
56
57
58
59
60
61
62
63
64
65
66
67
package fdbmeter
import (
"time"
"go.opentelemetry.io/otel/attribute"
)
type (
Option func(*options) error
options struct {
httpListenAddr string
fdbApiVersion int
fdbClusterFile string
statusRefreshInterval *time.Ticker
commonAttributes []attribute.KeyValue
}
)
func newOptions(o ...Option) (*options, error) {
opts := options{
httpListenAddr: "0.0.0.0:40080",
fdbApiVersion: 730,
statusRefreshInterval: time.NewTicker(10 * time.Second),
}
for _, apply := range o {
if err := apply(&opts); err != nil {
return nil, err
}
}
return &opts, nil
}
func WithHttpListenAddr(a string) Option {
return func(o *options) error {
o.httpListenAddr = a
return nil
}
}
func WithFdbApiVersion(v int) Option {
return func(o *options) error {
o.fdbApiVersion = v
return nil
}
}
func WithFdbClusterFile(cf string) Option {
return func(o *options) error {
o.fdbClusterFile = cf
return nil
}
}
func WithStatusRefreshInterval(d time.Duration) Option {
return func(o *options) error {
o.statusRefreshInterval = time.NewTicker(d)
return nil
}
}
func WithCommonAttributes(a ...attribute.KeyValue) Option {
return func(o *options) error {
o.commonAttributes = a
return nil
}
}