gearman-go/README.md

123 lines
3.1 KiB
Markdown
Raw Normal View History

2012-12-21 10:59:43 +08:00
Gearman-Go
2012-12-21 10:51:15 +08:00
==========
2013-06-09 12:31:25 +08:00
2013-12-25 17:01:42 +08:00
This module is a [Gearman](http://gearman.org/) API for the [Go Programming Language](http://golang.org).
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"
2013-12-26 16:02:30 +08:00
[![Build Status](https://travis-ci.org/mikespook/gearman-go.png?branch=master)](https://travis-ci.org/mikespook/gearman-go)
[![GoDoc](https://godoc.org/github.com/mikespook/gearman-go?status.png)](https://godoc.org/github.com/mikespook/gearman-go)
2012-12-21 11:11:37 +08:00
Install
=======
2012-05-24 19:57:06 +08:00
Install the client package:
2012-12-21 11:11:37 +08:00
> $ go get github.com/mikespook/gearman-go/client
2012-05-24 19:57:06 +08:00
Install the worker package:
2012-12-21 11:11:37 +08:00
> $ go get github.com/mikespook/gearman-go/worker
2013-12-25 17:01:42 +08:00
Both of them:
2012-12-21 11:11:37 +08:00
> $ go get github.com/mikespook/gearman-go
2012-12-21 11:11:37 +08:00
Usage
=====
## Worker
2015-01-20 10:27:12 +08:00
```go
2015-01-20 10:28:36 +08:00
// Limit number of concurrent jobs execution.
// Use worker.Unlimited (0) if you want no limitation.
2015-01-20 10:27:12 +08:00
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
2015-01-20 10:27:12 +08:00
```go
// ...
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(resp *client.Response) {
log.Printf("%s", resp.Data)
}
handle, err := c.Do("ToUpper", echo, client.JobNormal, jobHandler)
// ...
```
2013-08-30 11:20:51 +08:00
Branches
========
Version 0.x means: _It is far far away from stable._
__Use at your own risk!__
* master current usable version
2013-12-25 17:01:42 +08:00
* 0.2-dev Refactoring a lot of things
* 0.1-testing Old API and some known issues, eg. [issue-14](https://github.com/mikespook/gearman-go/issues/14)
2013-08-30 11:20:51 +08:00
2014-01-15 10:04:41 +08:00
Contributors
============
2015-01-20 10:27:12 +08:00
Great thanks to all of you for your support and interest!
2014-01-15 10:04:41 +08:00
(_Alphabetic order_)
* [Alex Zylman](https://github.com/azylman)
2015-01-20 10:27:12 +08:00
* [C.R. Kirkwood-Watts](https://github.com/kirkwood)
2014-03-07 17:40:32 +08:00
* [Damian Gryski](https://github.com/dgryski)
2015-01-20 10:27:12 +08:00
* [Gabriel Cristian Alecu](https://github.com/AzuraMeta)
* [Graham Barr](https://github.com/gbarr)
2014-01-15 10:04:41 +08:00
* [Ingo Oeser](https://github.com/nightlyone)
* [jake](https://github.com/jbaikge)
2014-06-13 10:55:32 +08:00
* [Joe Higton](https://github.com/draxil)
2014-01-15 10:04:41 +08:00
* [Jonathan Wills](https://github.com/runningwild)
2014-03-11 10:08:20 +08:00
* [Kevin Darlington](https://github.com/kdar)
2014-01-15 10:04:41 +08:00
* [miraclesu](https://github.com/miraclesu)
* [Paul Mach](https://github.com/paulmach)
2015-01-20 10:27:12 +08:00
* [Randall McPherson](https://github.com/rlmcpherson)
2014-01-15 10:04:41 +08:00
* [Sam Grimee](https://github.com/sgrimee)
2015-01-20 10:27:12 +08:00
Maintainer
==========
* [Xing Xing](http://mikespook.com) &lt;<mikespook@gmail.com>&gt; [@Twitter](http://twitter.com/mikespook)
2012-03-26 14:10:15 +08:00
2012-12-21 11:11:37 +08:00
Open Source - MIT Software License
==================================
2012-03-26 14:10:15 +08:00
See LICENSE.