don't use sigillum

This commit is contained in:
Xing Xing 2015-07-10 20:30:35 +08:00
parent 503d523dbf
commit c6c6c9cac2

View File

@ -9,6 +9,10 @@ import (
"time" "time"
) )
var (
DefaultTimeout time.Duration = 1000
)
// One client connect to one server. // One client connect to one server.
// Use Pool for multi-connections. // Use Pool for multi-connections.
type Client struct { type Client struct {
@ -21,7 +25,7 @@ type Client struct {
conn net.Conn conn net.Conn
rw *bufio.ReadWriter rw *bufio.ReadWriter
RespTimeout time.Duration // response timeout for do() in ms ResponseTimeout time.Duration // response timeout for do() in ms
ErrorHandler ErrorHandler ErrorHandler ErrorHandler
} }
@ -34,7 +38,7 @@ func New(network, addr string) (client *Client, err error) {
respHandler: make(map[string]ResponseHandler, queueSize), respHandler: make(map[string]ResponseHandler, queueSize),
innerHandler: make(map[string]ResponseHandler, queueSize), innerHandler: make(map[string]ResponseHandler, queueSize),
in: make(chan *Response, queueSize), in: make(chan *Response, queueSize),
RespTimeout: 1000, ResponseTimeout: DefaultTimeout,
} }
client.conn, err = net.Dial(client.net, client.addr) client.conn, err = net.Dial(client.net, client.addr)
if err != nil { if err != nil {
@ -208,7 +212,7 @@ func (client *Client) do(funcname string, data []byte,
client.lastcall = "" client.lastcall = ""
return return
} }
var timer = time.After(client.RespTimeout * time.Millisecond) var timer = time.After(client.ResponseTimeout * time.Millisecond)
select { select {
case ret := <-result: case ret := <-result:
return ret.handle, ret.err return ret.handle, ret.err