• Stars
    star
    290
  • Rank 142,981 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

Learning-Go-zh-cn

ไธ€ๆœฌๅญฆไน  Go ่ฏญ่จ€็š„ๅ…่ดน็”ตๅญไนฆใ€‚
Go
2,640
star
2

gorbac

goRBAC provides a lightweight role-based access control (RBAC) implementation in Golang.
Go
1,509
star
3

goemphp

This package is built for Embedding PHP into Golang.
Go
217
star
4

gleam

An operation cluster based on MQTT
Go
54
star
5

golib

Go
52
star
6

ghoko

A web application that listens to web-hooks, scripted by Lua and written in Golang.
Go
38
star
7

possum

A micro web library for Go.
Go
19
star
8

wechat

Go
10
star
9

php_doozer

A Doozer extension for PHP
C
10
star
10

wc-api-golang

A Golang wrapper for the WooCommerce API.
Go
7
star
11

php_skynet

PHP Client and Server to Skynet
PHP
6
star
12

beacons

Beacons is a application that handling and passing data between systems, scripted by Lua and written in Golang.
Go
5
star
13

php-yaf-ppa

PHP-Yaf ppa source utils. Build .deb package for Ubuntu
Shell
5
star
14

schego

A lite weight schedule library for Golang
Go
3
star
15

raccoon

A simple web-spider framework driven by Golang and Lua.
Go
3
star
16

gpkg

This command provides a tool for searching and managing as well as querying information about golang packages.
Go
2
star
17

sortmap

SortMap illustrates how to build a sortable map in Golang. Also, this library can be used in a practical project.
Go
1
star
18

sts

STS: Secure Tunnel Server - a configurable and powerful ssh tunnel
Go
1
star
19

qrd

A HTTP service generating QR code
Go
1
star
20

RIP

Rest in peace, my friends. We will miss you.
1
star
21

dgg-ci

DGG-CI is a Docker, Git and Golang continuous integration environment.
Shell
1
star