diff --git a/router/forwarder/forwarder.go b/router/forwarder/forwarder.go index dd68ae463..8250d6b34 100644 --- a/router/forwarder/forwarder.go +++ b/router/forwarder/forwarder.go @@ -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 diff --git a/router/forwarder/options.go b/router/forwarder/options.go index 68f7eb42e..274c34017 100644 --- a/router/forwarder/options.go +++ b/router/forwarder/options.go @@ -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'") } }