Go to file
Jesús García Crespo adbe320074 Remove handle only when the job is done
This commit stops the client from removing the job handle from
client.jobhandlers when the worker has sent an update (e.g. WORK_STATUS)
without terminating its life.

WORK_DATA       |
WORK_WARNING    | => Notification
WORK_STATUS     |

WORK_COMPLETE   |
WORK_FAIL       | => Notification + End of life
WORK_EXCEPTION  |
2013-11-09 10:06:11 -08:00
client Remove handle only when the job is done 2013-11-09 10:06:11 -08:00
common issue 'use of closed network connection' of client fixed 2013-04-23 21:41:56 +08:00
example fixed for travis-ci 2013-06-09 12:35:35 +08:00
worker #14 fixed 2013-04-24 16:58:06 +08:00
.gitignore Initial commit 2012-12-20 18:51:15 -08:00
.hgtags Added tag 0.1.2 for changeset 67f11fa2301f 2012-09-02 22:43:20 +08:00
.travis.yml gearmand must be installed 2013-06-09 12:41:59 +08:00
gearman_test.go issue 'use of closed network connection' of client fixed 2013-04-23 21:41:56 +08:00
gearman.go moved to github 2012-12-21 11:11:37 +08:00
LICENSE Added the client 2011-05-19 20:10:53 +08:00
README.md added travis-ci 2013-06-09 12:31:25 +08:00

Gearman-Go

Build Status

This package is a Gearman API for Golang. It was implemented a native protocol for both worker and client API.

Install

Install the client package:

$ go get github.com/mikespook/gearman-go/client

Install the worker package:

$ go get github.com/mikespook/gearman-go/worker

Install both:

$ go get github.com/mikespook/gearman-go

Usage

Worker

w := worker.New(worker.Unlimited)
w.ErrHandler = func(e error) {
    log.Println(e)
}
w.AddServer("127.0.0.1:4730")
w.AddFunc("ToUpper", ToUpper, worker.Immediately)
w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
w.Work()

Client

c, err := client.New("127.0.0.1:4730")
// ...
defer c.Close()
data := []byte("Hello\x00 world")
c.ErrHandler = func(e error) {
    log.Println(e)
    panic(e)
}
jobHandler := func(job *client.Job) {
    log.Printf("%s", job.Data)
}
handle := c.Do("ToUpper", data, client.JOB_NORMAL, jobHandler)
// ...

Authors

Open Source - MIT Software License

Copyright (c) 2012 Xing Xing

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.