-
Notifications
You must be signed in to change notification settings - Fork 2
/
option.go
64 lines (54 loc) · 1.42 KB
/
option.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
// Package aiven provides a client for interacting with the Aiven API.
package aiven
import "time"
// Option is a function that configures the client.
type Option func(*aivenClient)
// DebugOpt whether should the client run in debug mode.
// For instance, to output debug information
func DebugOpt(debug bool) Option {
return func(d *aivenClient) {
d.Debug = debug
}
}
// UserAgentOpt sets User-Agent header
func UserAgentOpt(userAgent string) Option {
return func(d *aivenClient) {
d.UserAgent = userAgent
}
}
// TokenOpt runs the client with the given token
func TokenOpt(token string) Option {
return func(d *aivenClient) {
d.Token = token
}
}
// HostOpt API host url
func HostOpt(host string) Option {
return func(d *aivenClient) {
d.Host = host
}
}
// DoerOpt replaces underlying http client in aivenClient
func DoerOpt(doer Doer) Option {
return func(d *aivenClient) {
d.doer = doer
}
}
// RetryMaxOpt sets the maximum number of retries
func RetryMaxOpt(retryMax int) Option {
return func(d *aivenClient) {
d.RetryMax = retryMax
}
}
// RetryWaitMinOpt sets the minimum wait time between retries
func RetryWaitMinOpt(retryWaitMin time.Duration) Option {
return func(d *aivenClient) {
d.RetryWaitMin = retryWaitMin
}
}
// RetryWaitMaxOpt sets the maximum wait time between retries
func RetryWaitMaxOpt(retryWaitMax time.Duration) Option {
return func(d *aivenClient) {
d.RetryWaitMax = retryWaitMax
}
}