-
Notifications
You must be signed in to change notification settings - Fork 178
/
config.go
38 lines (31 loc) · 877 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
package synchronization
import (
"time"
core "github.com/onflow/flow-go/module/synchronization"
)
type Config struct {
PollInterval time.Duration
ScanInterval time.Duration
}
func DefaultConfig() *Config {
scanInterval := 2 * time.Second
pollInterval := time.Duration(core.DefaultQueuedHeightMultiplicity) * scanInterval
return &Config{
PollInterval: pollInterval,
ScanInterval: scanInterval,
}
}
type OptionFunc func(*Config)
// WithPollInterval sets a custom interval at which we scan for poll items
func WithPollInterval(interval time.Duration) OptionFunc {
return func(cfg *Config) {
cfg.PollInterval = interval
}
}
// WithScanInterval sets a custom interval at which we scan for pending items
// and batch them for requesting.
func WithScanInterval(interval time.Duration) OptionFunc {
return func(cfg *Config) {
cfg.ScanInterval = interval
}
}