forked from HeavyHorst/fluxrus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
45 lines (37 loc) · 889 Bytes
/
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
package fluxrus
import (
"time"
influx "github.com/influxdata/influxdb/client/v2"
)
// Option configures the Hook
type Option func(*InfluxHook)
// WithBatchInterval sets the batchInterval
func WithBatchInterval(interval int) Option {
return func(o *InfluxHook) {
o.batchInterval = time.Duration(interval) * time.Second
}
}
// WithBatchSize sets the batchSize
func WithBatchSize(count int) Option {
return func(o *InfluxHook) {
o.batchSize = count
}
}
// WithPrecision sets the precision
func WithPrecision(p string) Option {
return func(o *InfluxHook) {
o.precision = p
}
}
// WithTags sets the tags that we will extract from the log fields
func WithTags(t []string) Option {
return func(o *InfluxHook) {
o.tags = t
}
}
// WithClient overwrites the default influx.Client
func WithClient(c influx.Client) Option {
return func(o *InfluxHook) {
o.client = c
}
}