-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
54 lines (45 loc) · 963 Bytes
/
config.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
package walker
import (
"context"
"time"
)
type Option func(*config)
type config struct {
maxBatchSize int
parallelism int
pagination Pagination
limiter Limiter
rateLimit rateLimit
context context.Context
contextCancel context.CancelFunc
}
func WithMaxBatchSize(size int) Option {
return func(c *config) {
c.maxBatchSize = size
}
}
func WithParallelism(parallelism int) Option {
return func(c *config) {
c.parallelism = parallelism
}
}
func WithLimiter(limiter Limiter) Option {
return func(c *config) {
c.limiter = limiter
}
}
func WithPagination(pagination Pagination) Option {
return func(c *config) {
c.pagination = pagination
}
}
func WithContext(ctx context.Context) Option {
return func(c *config) {
c.context, c.contextCancel = context.WithCancel(ctx)
}
}
func WithRateLimit(count int, per time.Duration) Option {
return func(c *config) {
c.rateLimit = rateLimit{count: count, per: per}
}
}