github.com/koko1123/flow-go-1@v0.29.6/engine/common/synchronization/config.go (about) 1 package synchronization 2 3 import ( 4 "time" 5 6 core "github.com/koko1123/flow-go-1/module/chainsync" 7 ) 8 9 type Config struct { 10 PollInterval time.Duration 11 ScanInterval time.Duration 12 } 13 14 func DefaultConfig() *Config { 15 scanInterval := 2 * time.Second 16 pollInterval := time.Duration(core.DefaultQueuedHeightMultiplicity) * scanInterval 17 return &Config{ 18 PollInterval: pollInterval, 19 ScanInterval: scanInterval, 20 } 21 } 22 23 type OptionFunc func(*Config) 24 25 // WithPollInterval sets a custom interval at which we scan for poll items 26 func WithPollInterval(interval time.Duration) OptionFunc { 27 return func(cfg *Config) { 28 cfg.PollInterval = interval 29 } 30 } 31 32 // WithScanInterval sets a custom interval at which we scan for pending items 33 // and batch them for requesting. 34 func WithScanInterval(interval time.Duration) OptionFunc { 35 return func(cfg *Config) { 36 cfg.ScanInterval = interval 37 } 38 }