Wire up forwarder.scanner configuration. (#173)

This commit is contained in:
Michael Quigley
2021-03-04 14:33:23 -05:00
parent 9efd5ede01
commit d48a13f513
2 changed files with 23 additions and 3 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ func NewForwarder(metricsRegistry metrics.UsageRegistry, faulter *Faulter, optio
Options: options,
CloseNotify: closeNotify,
}
forwarder.scanner = newScanner(forwarder.sessions, 30 * time.Second, 30 * time.Second, forwarder.CloseNotify)
forwarder.scanner = newScanner(forwarder.sessions, options.IdleTxInterval, options.IdleSessionTimeout, forwarder.CloseNotify)
go forwarder.scanner.run()
return forwarder
+22 -2
View File
@@ -26,6 +26,8 @@ type Options struct {
LatencyProbeTimeout time.Duration
XgressCloseCheckInterval time.Duration
FaultTxInterval time.Duration
IdleTxInterval time.Duration
IdleSessionTimeout time.Duration
XgressDial WorkerPoolOptions
LinkDial WorkerPoolOptions
}
@@ -38,9 +40,11 @@ type WorkerPoolOptions struct {
func DefaultOptions() *Options {
return &Options{
LatencyProbeInterval: 10 * time.Second,
LatencyProbeTimeout: 10 * time.Second,
LatencyProbeTimeout: 10 * time.Second,
XgressCloseCheckInterval: 5 * time.Second,
FaultTxInterval: 15 * time.Second,
IdleTxInterval: 60 * time.Second,
IdleSessionTimeout: 60 * time.Second,
XgressDial: WorkerPoolOptions{
QueueLength: 1000,
WorkerCount: 10,
@@ -83,7 +87,23 @@ func LoadOptions(src map[interface{}]interface{}) (*Options, error) {
if val, ok := value.(int); ok {
options.FaultTxInterval = time.Duration(val) * time.Millisecond
} else {
return nil, errors.New("invalid value for 'faultTxInterval")
return nil, errors.New("invalid value for 'faultTxInterval'")
}
}
if value, found := src["idleTxInterval"]; found {
if val, ok := value.(int); ok {
options.IdleTxInterval = time.Duration(val) * time.Millisecond
} else {
return nil, errors.New("invalid value for 'idleTxInterval'")
}
}
if value, found := src["idleSessionTimeout"]; found {
if val, ok := value.(int); ok {
options.IdleSessionTimeout = time.Duration(val) * time.Millisecond
} else {
return nil, errors.New("invalid value for 'idleSessionTimeout'")
}
}