gearman-go

This package is a Gearman API for Golang. It was implemented a native protocol for both worker and client API.

  • Owner: mikespook/gearman-go
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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(resp *client.Response) {
	log.Printf("%s", resp.Data)
}
handle, err := c.Do("ToUpper", echo, client.JobNormal, 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

Great thanks to all of you for your support and interest!

(Alphabetic order)

Maintainer

Open Source - MIT Software License

See LICENSE.

Main metrics

Overview
Name With Ownermikespook/gearman-go
Primary LanguageGo
Program languageGo (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2012-12-21 02:51:14
Pushed At2022-05-20 03:14:03
Last Commit At2022-05-20 15:14:03
Release Count6
Last Release Name0.2 (Posted on )
First Release Name0.0.1 (Posted on )
用户参与
Stargazers Count290
Watchers Count25
Fork Count83
Commits Count290
Has Issues Enabled
Issues Count47
Issue Open Count16
Pull Requests Count34
Pull Requests Open Count2
Pull Requests Close Count13
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private