-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoption.go
More file actions
55 lines (45 loc) · 969 Bytes
/
option.go
File metadata and controls
55 lines (45 loc) · 969 Bytes
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
package zkclient
import (
"time"
"github.com/funkygao/go-zookeeper/zk"
)
// Option is a func that can setup a Client's option.
type Option func(*Client)
func WithSessionTimeout(sessionTimeout time.Duration) Option {
return func(c *Client) {
c.sessionTimeout = sessionTimeout
}
}
func WithWrapErrorWithPath() Option {
return func(c *Client) {
c.wrapErrorWithPath = true
}
}
func WithACL(acl []zk.ACL) Option {
return func(c *Client) {
c.acl = acl
}
}
func WithRetryAttempts(attempts int) Option {
return func(c *Client) {
c.withRetry = true
zkRetryOptions.MaxAttempts = attempts
}
}
func WithRetryLog(useV1Info bool) Option {
return func(c *Client) {
c.withRetry = true
zkRetryOptions.UseV1Info = useV1Info
}
}
func WithRetryBackoff(backoff time.Duration) Option {
return func(c *Client) {
c.withRetry = true
zkRetryOptions.Backoff = backoff
}
}
func WithoutRetry() Option {
return func(c *Client) {
c.withRetry = false
}
}