Documentation ¶
Index ¶
- Constants
- Variables
- func SelectRandom(pool map[string]*poolClient, last string) (addr string)
- func SelectWithRate(pool map[string]*poolClient, last string) (addr string)
- type Client
- func (client *Client) Close() (err error)
- func (client *Client) Do(funcname string, data []byte, flag byte, jobhandler JobHandler) (handle string)
- func (client *Client) DoBg(funcname string, data []byte, flag byte) (handle string)
- func (client *Client) Echo(data []byte, timeout time.Duration) (r []byte, err error)
- func (client *Client) Status(handle string, timeout time.Duration) (status *Status, err error)
- type ErrorHandler
- type IdGenerator
- type Job
- type JobHandler
- type Pool
- func (pool *Pool) Add(addr string, rate int) (err error)
- func (pool *Pool) Close() (err map[string]error)
- func (pool *Pool) Do(funcname string, data []byte, flag byte, h JobHandler) (addr, handle string)
- func (pool *Pool) DoBg(funcname string, data []byte, flag byte) (addr, handle string)
- func (pool *Pool) Echo(addr string, data []byte, timeout time.Duration) (r []byte, err error)
- func (pool *Pool) Remove(addr string)
- func (pool *Pool) Status(addr, handle string, timeout time.Duration) (status *Status, err error)
- type SelectionHandler
- type Status
- type StatusHandler
Constants ¶
View Source
const ( // Job type // JOB_NORMAL | JOB_BG means a normal level job run in background // normal level JOB_NORMAL = 0 // background job JOB_BG = 1 // low level JOB_LOW = 2 // high level JOB_HIGH = 4 )
View Source
const (
PoolSize = 10
)
Variables ¶
View Source
var (
ErrNotFound = errors.New("Server Not Found")
)
Functions ¶
func SelectRandom ¶
func SelectWithRate ¶
Types ¶
type Client ¶
type Client struct { ErrHandler common.ErrorHandler TimeOut time.Duration // contains filtered or unexported fields }
The client side api for gearman
usage: c := client.New("tcp4", "127.0.0.1:4730") handle := c.Do("foobar", []byte("data here"), JOB_LOW | JOB_BG)
func New ¶
Create a new client. Connect to "addr" through "network" Eg.
client, err := client.New("127.0.0.1:4730")
func (*Client) Do ¶
func (client *Client) Do(funcname string, data []byte, flag byte, jobhandler JobHandler) (handle string)
Do the function. funcname is a string with function name. data is encoding to byte array. flag set the job type, include running level: JOB_LOW, JOB_NORMAL, JOB_HIGH, and if it is background job: JOB_BG. JOB_LOW | JOB_BG means the job is running with low level in background.
type IdGenerator ¶
type IdGenerator interface {
Id() string
}
var (
IdGen IdGenerator
)
func NewAutoIncId ¶
func NewAutoIncId() IdGenerator
func NewObjectId ¶
func NewObjectId() IdGenerator
type Job ¶
type Job struct { Data []byte Handle, UniqueId string DataType uint32 // contains filtered or unexported fields }
Client side job
type Pool ¶
type Pool struct { SelectionHandler SelectionHandler ErrHandler common.ErrorHandler // contains filtered or unexported fields }
type SelectionHandler ¶
Click to show internal directories.
Click to hide internal directories.