Add options for controlling reconnect delay growth
This commit is contained in:
parent
a1abfdc3d6
commit
69ad2a9c03
3 changed files with 30 additions and 1 deletions
|
@ -75,6 +75,8 @@ class MockConfig(object):
|
||||||
'print_unconfirmed_messages': None,
|
'print_unconfirmed_messages': None,
|
||||||
'read_markers_conditions': None,
|
'read_markers_conditions': None,
|
||||||
'typing_notice_conditions': None,
|
'typing_notice_conditions': None,
|
||||||
|
'autoreconnect_delay_growing': None,
|
||||||
|
'autoreconnect_delay_max': None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,6 +629,26 @@ class MatrixConfig(WeechatConfig):
|
||||||
("Reconnect to the server if the lag is greater than this "
|
("Reconnect to the server if the lag is greater than this "
|
||||||
"value (in seconds)"),
|
"value (in seconds)"),
|
||||||
),
|
),
|
||||||
|
Option(
|
||||||
|
"autoreconnect_delay_growing",
|
||||||
|
"integer",
|
||||||
|
"",
|
||||||
|
1,
|
||||||
|
100,
|
||||||
|
"2",
|
||||||
|
("growing factor for autoreconnect delay to server "
|
||||||
|
"(1 = always same delay, 2 = delay*2 for each retry, etc.)"),
|
||||||
|
),
|
||||||
|
Option(
|
||||||
|
"autoreconnect_delay_max",
|
||||||
|
"integer",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
604800,
|
||||||
|
"600",
|
||||||
|
("maximum autoreconnect delay to server "
|
||||||
|
"(in seconds, 0 = no maximum)"),
|
||||||
|
),
|
||||||
Option(
|
Option(
|
||||||
"print_unconfirmed_messages",
|
"print_unconfirmed_messages",
|
||||||
"boolean",
|
"boolean",
|
||||||
|
|
|
@ -671,10 +671,17 @@ class MatrixServer(object):
|
||||||
self.reconnect_time = time.time()
|
self.reconnect_time = time.time()
|
||||||
|
|
||||||
if self.reconnect_delay:
|
if self.reconnect_delay:
|
||||||
self.reconnect_delay = self.reconnect_delay * 2
|
self.reconnect_delay = (
|
||||||
|
self.reconnect_delay
|
||||||
|
* G.CONFIG.network.autoreconnect_delay_growing
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.reconnect_delay = self.config.reconnect_delay
|
self.reconnect_delay = self.config.reconnect_delay
|
||||||
|
|
||||||
|
if G.CONFIG.network.autoreconnect_delay_max > 0:
|
||||||
|
self.reconnect_delay = min(self.reconnect_delay,
|
||||||
|
G.CONFIG.network.autoreconnect_delay_max)
|
||||||
|
|
||||||
message = (
|
message = (
|
||||||
"{prefix}matrix: reconnecting to server in {t} " "seconds"
|
"{prefix}matrix: reconnecting to server in {t} " "seconds"
|
||||||
).format(prefix=W.prefix("network"), t=self.reconnect_delay)
|
).format(prefix=W.prefix("network"), t=self.reconnect_delay)
|
||||||
|
|
Loading…
Reference in a new issue