-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
46 lines (39 loc) · 803 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
package axcelerate
import (
"net/http"
"time"
)
type Option func(s *Settings)
// // PublisherOptions are used to describe a publisher's configuration.
// // Logger is a custom logging interface.
// type Option struct {
// BaseURL string
// Rate Logger
// HttpClient *http.Client
// }
func BaseURL(baseURL string) Option {
return func(s *Settings) {
s.baseURL = baseURL
}
}
func HttpClient(httpClient *http.Client) Option {
return func(s *Settings) {
s.httpClient = httpClient
}
}
func RateLimit(rate int) Option {
return func(s *Settings) {
s.rate = rate
}
}
func RatePer(ratePer time.Duration) Option {
return func(s *Settings) {
s.ratePer = ratePer
}
}
type Settings struct {
baseURL string
httpClient *http.Client
rate int
ratePer time.Duration
}