Stubborn helpers for gearman-go
Currently, a default error handler for https://github.com/mikespook/gearman-go which will maintain server connections on disconnect, stubbonly trying to reconnect to servers until they come back.
Basic usage:
import (
"github.com/mikespook/gearman-go/worker"
"github.com/draxil/gearman-go-stubborn/worker/stubborn"
)
// then:
w := worker.New(worker.Unlimited)
w.ErrorHandler = stubborn.MakeErrorHandler(nil)
Or for the lazy:
import (
"github.com/mikespook/gearman-go/worker"
"github.com/draxil/gearman-go-stubborn/worker/stubborn"
)
w := stubborn.NewStubbornWorker(worker.Unlimited, nil)
Which will invoke the creation of the worker and assign the error handler for you. You can pass in settings to influence the behaviour of the handler and/or layer on your own error handler for non D/C errors.
See the godoc for details (or the tests if you are brave).