[#370] Ability to configure ping_interval and ping_max (with tests)

This commit is contained in:
Volodymyr Khoroz
2016-11-15 16:04:26 +02:00
parent 30197b046e
commit a98b51a5ca
3 changed files with 12 additions and 0 deletions

View File

@@ -36,3 +36,7 @@ max_payload: 65536
# slow consumer threshold
max_pending_size: 10000000
# ping interval and no pong threshold
ping_interval: 60
ping_max: 3

View File

@@ -216,6 +216,10 @@ func ProcessConfigFile(configFile string) (*Options, error) {
opts.MaxPending = int(v.(int64))
case "max_connections", "max_conn":
opts.MaxConn = int(v.(int64))
case "ping_interval":
opts.PingInterval = time.Duration(int(v.(int64)))
case "ping_max":
opts.MaxPingsOut = int(v.(int64))
case "tls":
tlsm := v.(map[string]interface{})
tc, err := parseTLS(tlsm)

View File

@@ -67,6 +67,8 @@ func TestConfigFile(t *testing.T) {
MaxPayload: 65536,
MaxConn: 100,
MaxPending: 10000000,
PingInterval: 60,
MaxPingsOut: 3,
}
opts, err := ProcessConfigFile("./configs/test.conf")
@@ -187,6 +189,8 @@ func TestMergeOverrides(t *testing.T) {
MaxPayload: 65536,
MaxConn: 100,
MaxPending: 10000000,
PingInterval: 60,
MaxPingsOut: 3,
ClusterNoAdvertise: true,
}
fopts, err := ProcessConfigFile("./configs/test.conf")