Go to file
2012-06-04 16:12:06 +08:00
client using time.After instead of a separate goroutine 2012-05-30 09:54:22 +08:00
common fixed the merge error 2012-05-28 10:43:08 +08:00
example fixed the example 2012-06-01 14:28:10 +08:00
worker added a timeout at the worker side 2012-06-04 16:12:06 +08:00
.hgtags Removed tag go1-0.1, go1-0.0.1 2012-05-29 08:47:13 +08:00
gearman.go fixing for 'go install' 2012-05-24 16:56:36 +08:00
LICENSE Added the client 2011-05-19 20:10:53 +08:00
README.md promoted the README 2012-05-24 19:57:06 +08:00

Gearman API for golang

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

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

SAMPLE OF 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, 0)
w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
w.Work()

Client

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)
// ...

Contacts

Xing Xing mikespook@gmail.com

Blog

@Twitter

History

  • 0.1 Code refactoring; Redesign the API.
  • 0.0.1 Initial implementation, ugly code-style, slow profermance and unstable API.

TODO

  • Can not grab a job correctly.
  • Worker's auto-reconnection.