-
Notifications
You must be signed in to change notification settings - Fork 6
/
options.go
36 lines (30 loc) · 865 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
package statsd
import (
"time"
)
// Option is the interface that allows to set client options.
type Option func(c *Client)
// WithPrefix sets the StatsD client's string prefix that will be used in every bucket name.
func WithPrefix(prefix string) Option {
return func(c *Client) {
c.prefix = prefix
}
}
// WithNetwork sets the network type used by the StatsD client (i.e. udp or tcp).
func WithNetwork(network string) Option {
return func(c *Client) {
c.network = network
}
}
// WithAddress sets the network address of the StatsD daemon (ip:port) or just (:port).
func WithAddress(address string) Option {
return func(c *Client) {
c.address = address
}
}
// WithFlushPeriod sets how often the StatsD client's buffer is flushed.
func WithFlushPeriod(flushPeriod time.Duration) Option {
return func(c *Client) {
c.flushPeriod = flushPeriod
}
}