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.
This commit is contained in:
Reto Brunner 2019-07-18 06:25:42 +02:00 committed by Drew DeVault
parent 66a9052f0f
commit 6fed04bb9f
5 changed files with 53 additions and 20 deletions
worker/imap

View file

@ -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 {