-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.go
50 lines (39 loc) · 968 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
46
47
48
49
50
package httpc
type HttpClientParams struct {
MaxRetryWait int
MaxRetries int
}
type HttpClientOptions func(*HttpClientParams)
func newHttpClientParams(opts ...HttpClientOptions) *HttpClientParams {
s := &HttpClientParams{
MaxRetryWait: 10,
MaxRetries: 3,
} //default values
for _, opt := range opts {
opt(s)
}
return s
}
func WithMaxRetryWait(maxRetryWait int) HttpClientOptions {
return func(s *HttpClientParams) {
s.MaxRetryWait = maxRetryWait
}
}
func WithMaxRetries(maxRetries int) HttpClientOptions {
return func(s *HttpClientParams) {
s.MaxRetries = maxRetries
}
}
// getters and setters -----
func (s *HttpClientParams) GetMaxRetryWait() int {
return s.MaxRetryWait
}
func (s *HttpClientParams) SetMaxRetryWait(maxRetryWait int) {
s.MaxRetryWait = maxRetryWait
}
func (s *HttpClientParams) GetMaxRetries() int {
return s.MaxRetries
}
func (s *HttpClientParams) SetMaxRetries(maxRetries int) {
s.MaxRetries = maxRetries
}