forked from yuxh/gearman-go
		
	Merge pull request #87 from CodeLingoBot/rewrite
Fix function comments based on best practices from Effective Go
This commit is contained in:
		
						commit
						b902646ce8
					
				@ -62,7 +62,7 @@ func (r *responseHandlerMap) putNoLock(key string, rh ResponseHandler) {
 | 
			
		||||
	r.holder[key] = rh
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return a client.
 | 
			
		||||
// New returns a client.
 | 
			
		||||
func New(network, addr string) (client *Client, err error) {
 | 
			
		||||
	client = &Client{
 | 
			
		||||
		net:             network,
 | 
			
		||||
@ -293,7 +293,7 @@ func (client *Client) DoBg(funcname string, data []byte,
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get job status from job server.
 | 
			
		||||
// Status gets job status from job server.
 | 
			
		||||
func (client *Client) Status(handle string) (status *Status, err error) {
 | 
			
		||||
	if client.conn == nil {
 | 
			
		||||
		return nil, ErrLostConn
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ func (ai *autoincId) Id() string {
 | 
			
		||||
	return strconv.FormatInt(next, 10)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return an autoincrement ID generator
 | 
			
		||||
// NewAutoIncId returns an autoincrement ID generator
 | 
			
		||||
func NewAutoIncId() IdGenerator {
 | 
			
		||||
	// we'll consider the nano fraction of a second at startup unique
 | 
			
		||||
	// and count up from there.
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ type Pool struct {
 | 
			
		||||
	mutex sync.Mutex
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return a new pool.
 | 
			
		||||
// NewPool returns a new pool.
 | 
			
		||||
func NewPool() (pool *Pool) {
 | 
			
		||||
	return &Pool{
 | 
			
		||||
		Clients:          make(map[string]*PoolClient, poolSize),
 | 
			
		||||
@ -111,7 +111,7 @@ func (pool *Pool) DoBg(funcname string, data []byte,
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get job status from job server.
 | 
			
		||||
// Status gets job status from job server.
 | 
			
		||||
// !!!Not fully tested.!!!
 | 
			
		||||
func (pool *Pool) Status(addr, handle string) (status *Status, err error) {
 | 
			
		||||
	if client, ok := pool.Clients[addr]; ok {
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@ type Worker struct {
 | 
			
		||||
	limit        chan bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return a worker.
 | 
			
		||||
// New returns a worker.
 | 
			
		||||
//
 | 
			
		||||
// If limit is set to Unlimited(=0), the worker will grab all jobs
 | 
			
		||||
// and execute them parallelly.
 | 
			
		||||
@ -56,7 +56,7 @@ func (worker *Worker) err(e error) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Add a Gearman job server.
 | 
			
		||||
// AddServer adds a Gearman job server.
 | 
			
		||||
//
 | 
			
		||||
// addr should be formated as 'host:port'.
 | 
			
		||||
func (worker *Worker) AddServer(net, addr string) (err error) {
 | 
			
		||||
@ -76,7 +76,7 @@ func (worker *Worker) broadcast(outpack *outPack) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Add a function.
 | 
			
		||||
// AddFunc adds a function.
 | 
			
		||||
// Set timeout as Unlimited(=0) to disable executing timeout.
 | 
			
		||||
func (worker *Worker) AddFunc(funcname string,
 | 
			
		||||
	f JobFunc, timeout uint32) (err error) {
 | 
			
		||||
@ -116,7 +116,7 @@ func prepFuncOutpack(funcname string, timeout uint32) *outPack {
 | 
			
		||||
	return outpack
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Remove a function.
 | 
			
		||||
// RemoveFunc removes a function.
 | 
			
		||||
func (worker *Worker) RemoveFunc(funcname string) (err error) {
 | 
			
		||||
	worker.Lock()
 | 
			
		||||
	defer worker.Unlock()
 | 
			
		||||
@ -237,7 +237,7 @@ func (worker *Worker) Echo(data []byte) {
 | 
			
		||||
	worker.broadcast(outpack)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Remove all of functions.
 | 
			
		||||
// Reset removes all of functions.
 | 
			
		||||
// Both from the worker and job servers.
 | 
			
		||||
func (worker *Worker) Reset() {
 | 
			
		||||
	outpack := getOutPack()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user