Go to file
Joe Higton 2f72b28d76 FIX: waiting for worker fireup was making the test slow
Dodging the race condition with a sleep was fine, but we slept
for a whole second which was longer than this test takes to run!

I've scaled the sleep down to 250 miliseconds and increased the tries.

Even this is probably excessively long but now the test is fast agin.
2014-06-07 05:35:05 +01:00
client Make pool clients safe for concurrent access with mutex. 2014-05-16 10:23:44 -04:00
example Merge branch 'master' into 0.2-dev 2014-03-07 17:33:16 +08:00
worker FIX: waiting for worker fireup was making the test slow 2014-06-07 05:35:05 +01:00
.gitignore Initial commit 2012-12-20 18:51:15 -08:00
.travis.yml a better documents 2013-12-26 12:06:47 +08:00
gearman.go a better doc 2013-12-25 18:11:01 +08:00
LICENSE Added the client 2011-05-19 20:10:53 +08:00
README.md SUBMIT_JOB_SCHED is deprecated, worker.Immediately should be removed. 2014-01-16 09:43:06 +08:00

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"

Build Status GoDoc

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)

Open Source - MIT Software License

See LICENSE.