forked from yuxh/gearman-go
		
	don't use sigillum
This commit is contained in:
		
							parent
							
								
									503d523dbf
								
							
						
					
					
						commit
						c6c6c9cac2
					
				@ -9,6 +9,10 @@ import (
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	DefaultTimeout time.Duration = 1000
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// One client connect to one server.
 | 
			
		||||
// Use Pool for multi-connections.
 | 
			
		||||
type Client struct {
 | 
			
		||||
@ -21,7 +25,7 @@ type Client struct {
 | 
			
		||||
	conn                net.Conn
 | 
			
		||||
	rw                  *bufio.ReadWriter
 | 
			
		||||
 | 
			
		||||
	RespTimeout         time.Duration  // response timeout for do() in ms
 | 
			
		||||
	ResponseTimeout time.Duration // response timeout for do() in ms
 | 
			
		||||
 | 
			
		||||
	ErrorHandler ErrorHandler
 | 
			
		||||
}
 | 
			
		||||
@ -34,7 +38,7 @@ func New(network, addr string) (client *Client, err error) {
 | 
			
		||||
		respHandler:     make(map[string]ResponseHandler, queueSize),
 | 
			
		||||
		innerHandler:    make(map[string]ResponseHandler, queueSize),
 | 
			
		||||
		in:              make(chan *Response, queueSize),
 | 
			
		||||
		RespTimeout:  1000,
 | 
			
		||||
		ResponseTimeout: DefaultTimeout,
 | 
			
		||||
	}
 | 
			
		||||
	client.conn, err = net.Dial(client.net, client.addr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -208,7 +212,7 @@ func (client *Client) do(funcname string, data []byte,
 | 
			
		||||
		client.lastcall = ""
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	var timer = time.After(client.RespTimeout * time.Millisecond)
 | 
			
		||||
	var timer = time.After(client.ResponseTimeout * time.Millisecond)
 | 
			
		||||
	select {
 | 
			
		||||
	case ret := <-result:
 | 
			
		||||
		return ret.handle, ret.err
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user