From 6fed04bb9fa43d3886d47d0c845d32fff11569b5 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Thu, 18 Jul 2019 06:25:42 +0200 Subject: Register worker in init. This allows backends which can't always be compiled due to missing dependencies (say libnotmuch) to be compiled conditionally with buildflags. --- worker/imap/worker.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'worker/imap') diff --git a/worker/imap/worker.go b/worker/imap/worker.go index de869941..b1ef9c91 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -13,9 +13,15 @@ import ( "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/models" + "git.sr.ht/~sircmpwn/aerc/worker/handlers" "git.sr.ht/~sircmpwn/aerc/worker/types" ) +func init() { + handlers.RegisterWorkerFactory("imap", NewIMAPWorker) + handlers.RegisterWorkerFactory("imaps", NewIMAPWorker) +} + var errUnsupported = fmt.Errorf("unsupported command") type imapClient struct { @@ -43,12 +49,12 @@ type IMAPWorker struct { seqMap []uint32 } -func NewIMAPWorker(worker *types.Worker) *IMAPWorker { +func NewIMAPWorker(worker *types.Worker) (types.Backend, error) { return &IMAPWorker{ idleDone: make(chan error), updates: make(chan client.Update, 50), worker: worker, - } + }, nil } func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { -- cgit