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