Giter Site home page Giter Site logo

pablogupi / gearman-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mikespook/gearman-go

0.0 1.0 0.0 3.3 MB

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

License: MIT License

Go 97.07% Python 2.93%

gearman-go's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.