summaryrefslogtreecommitdiff
path: root/worker/imap/configure.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-04-30 01:08:56 +0200
committerRobin Jarry <robin@jarry.cc>2022-05-04 14:07:15 +0200
commite5b339702a56fa02dedec770a79b64313fb30108 (patch)
treee9c345f5043c5cf748bc6e25c6be6c1bb173d33f /worker/imap/configure.go
parent397a6f267f41c501f28d3adb9d641a9283af474f (diff)
downloadaerc-e5b339702a56fa02dedec770a79b64313fb30108.zip
imap: monitor the logout channel with an observer
Untangle the observer functionality from the message handling routine. Observe the imap client's logout channel and trigger a connection error when necessary to start the reconnect cycle. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/imap/configure.go')
-rw-r--r--worker/imap/configure.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/worker/imap/configure.go b/worker/imap/configure.go
index 0bccbae..c25600d 100644
--- a/worker/imap/configure.go
+++ b/worker/imap/configure.go
@@ -50,6 +50,9 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error {
w.config.keepalive_period = 0 * time.Second
w.config.keepalive_probes = 3
w.config.keepalive_interval = 3
+
+ w.config.reconnect_maxwait = 30 * time.Second
+
for key, value := range msg.Config.Params {
switch key {
case "idle-timeout":
@@ -60,6 +63,14 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error {
value, err)
}
w.config.idle_timeout = val
+ case "reconnect-maxwait":
+ val, err := time.ParseDuration(value)
+ if err != nil || val < 0 {
+ return fmt.Errorf(
+ "invalid reconnect-maxwait value %v: %v",
+ value, err)
+ }
+ w.config.reconnect_maxwait = val
case "connection-timeout":
val, err := time.ParseDuration(value)
if err != nil || val < 0 {
@@ -96,6 +107,7 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error {
}
w.idler = newIdler(w.config, w.worker)
+ w.observer = newObserver(w.config, w.worker)
return nil
}