diff --git a/example/worker.go b/example/worker.go index d5f162f..18fed29 100644 --- a/example/worker.go +++ b/example/worker.go @@ -22,6 +22,15 @@ func main() { defer w.Close() w.ErrHandler = func(e error) { log.Println(e) + if e == worker.ErrConnection { + proc, err := os.FindProcess(os.Getpid()) + if err != nil { + log.Println(err) + } + if err := proc.Signal(os.Interrupt); err != nil { + log.Println(err) + } + } } w.JobHandler = func(job *worker.Job) error { log.Printf("H=%s, UID=%s, Data=%s\n", job.Handle, diff --git a/worker/worker.go b/worker/worker.go index 35af432..708a7f2 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -13,6 +13,10 @@ const ( Unlimited = 0 OneByOne = 1 ) + +var ( + ErrConnection = common.ErrConnection +) // Job handler type JobHandler func(*Job) error