diff --git a/client/client.go b/client/client.go index 6de4212..4a3aa8f 100644 --- a/client/client.go +++ b/client/client.go @@ -82,7 +82,7 @@ func (client *Client) inLoop() { for { rel, err := client.read() if err != nil { - if err == common.ErrEmptyReading { + if err == common.ErrConnection { client.Close() break } @@ -123,7 +123,7 @@ func (client *Client) read() (data []byte, err error) { if n, err = client.conn.Read(buf); err != nil { if err == io.EOF && n == 0 { if data == nil { - err = common.ErrEmptyReading + err = common.ErrConnection return } break diff --git a/common/error.go b/common/error.go index 463af2d..23d2879 100644 --- a/common/error.go +++ b/common/error.go @@ -22,7 +22,7 @@ var ( ErrOutOfCap = errors.New("Out of the capability.") ErrNotConn = errors.New("Did not connect to job server.") ErrFuncNotFound = errors.New("The function was not found.") - ErrEmptyReading = errors.New("Empty reading.") + ErrConnection = errors.New("Connection error.") ) func DisablePanic() {recover()} diff --git a/worker/agent.go b/worker/agent.go index ceef56a..4e92209 100644 --- a/worker/agent.go +++ b/worker/agent.go @@ -61,7 +61,8 @@ func (a *agent) inLoop() { } rel, err := a.read() if err != nil { - if err == common.ErrEmptyReading { + if err == common.ErrConnection { + // TODO: reconnection break } a.worker.err(err) @@ -102,7 +103,7 @@ func (a *agent) read() (data []byte, err error) { if n, err = a.conn.Read(buf); err != nil { if err == io.EOF && n == 0 { if data == nil { - err = common.ErrEmptyReading + err = common.ErrConnection return } break