mikespook b7c858553c | il y a 12 ans | |
---|---|---|
client | il y a 12 ans | |
common | il y a 12 ans | |
example | il y a 12 ans | |
worker | il y a 12 ans | |
.hgtags | il y a 12 ans | |
LICENSE | il y a 13 ans | |
README.md | il y a 12 ans | |
gearman.go | il y a 12 ans |
This package is a Gearman API for Golang. It was implemented a native protocol for both worker and client API.
Copyright 2012 Xing Xing mikespook@gmail.com All rights reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file.
Install the client package:
$ go get bitbucket.org/mikespook/gearman-go/client
Install the worker package:
$ go get bitbucket.org/mikespook/gearman-go/worker
Install both:
$ go get bitbucket.org/mikespook/gearman-go
w := worker.New(worker.Unlimited)
w.ErrHandler = func(e error) {
log.Println(e)
}
w.AddServer("127.0.0.1:4730")
w.AddFunc("ToUpper", ToUpper, 0)
w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
w.Work()
c, err := client.New("127.0.0.1:4730")
// ...
defer c.Close()
echo := []byte("Hello\x00 world")
c.JobHandler = func(job *client.Job) error {
log.Printf("%s", job.Data)
return nil
}
c.ErrHandler = func(e error) {
log.Println(e)
panic(e)
}
handle, err := c.Do("ToUpper", echo, client.JOB_NORMAL)
// ...
Xing Xing mikespook@gmail.com