fixed the example

This commit is contained in:
mikespook 2012-06-01 14:28:10 +08:00
parent b7c858553c
commit 83f5f6fa70
2 changed files with 13 additions and 0 deletions

View File

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

View File

@ -13,6 +13,10 @@ const (
Unlimited = 0
OneByOne = 1
)
var (
ErrConnection = common.ErrConnection
)
// Job handler
type JobHandler func(*Job) error