d82da8fd71
When receiving a response, what was happening 1. Read bufferSize and it gets assigned to leftdata 2. Read another bufferSize 3. 2 buffers get appended, but leftdata still points to first buffer 4. Process data buffer which contains only complete responses 5. Back to ReadLoop, but leftdata still points to first incomplete buffer causing corrupt data to be processed Solution is to make leftdata nil once we have merged it with the second buffer |
||
---|---|---|
client | ||
example | ||
worker | ||
.gitignore | ||
.travis.yml | ||
gearman.go | ||
LICENSE | ||
README.md |
Gearman-Go
This module is a Gearman API for the Go Programming Language. The protocols were written in pure Go. It contains two sub-packages:
The client package is used for sending jobs to the Gearman job server, and getting responses from the server.
"github.com/mikespook/gearman-go/client"
The worker package will help developers in developing Gearman worker service easily.
"github.com/mikespook/gearman-go/worker"
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
Both of them:
$ go get github.com/mikespook/gearman-go
Usage
Worker
// Limit number of concurrent jobs execution. Use worker.Unlimited (0) if you want no limitation.
w := worker.New(worker.OneByOne)
w.ErrHandler = func(e error) {
log.Println(e)
}
w.AddServer("127.0.0.1:4730")
// Use worker.Unlimited (0) if you want no timeout
w.AddFunc("ToUpper", ToUpper, worker.Unlimited)
// This will give a timeout of 5 seconds
w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
if err := w.Ready(); err != nil {
log.Fatal(err)
return
}
go w.Work()
Client
// ...
c, err := client.New("tcp4", "127.0.0.1:4730")
// ... error handling
defer c.Close()
c.ErrorHandler = func(e error) {
log.Println(e)
}
echo := []byte("Hello\x00 world")
echomsg, err := c.Echo(echo)
// ... error handling
log.Println(string(echomsg))
jobHandler := func(job *client.Job) {
log.Printf("%s", job.Data)
}
handle, err := c.Do("ToUpper", echo, client.JOB_NORMAL, jobHandler)
// ...
Branches
Version 0.x means: It is far far away from stable.
Use at your own risk!
- master current usable version
- 0.2-dev Refactoring a lot of things
- 0.1-testing Old API and some known issues, eg. issue-14
Contributors
(Alphabetic order)
- Alex Zylman
- Damian Gryski
- Ingo Oeser
- jake
- Joe Higton
- Jonathan Wills
- Kevin Darlington
- miraclesu
- Paul Mach
- Sam Grimee
- suchj
- Xing Xing mikespook@gmail.com @Twitter
Open Source - MIT Software License
See LICENSE.