diff --git a/client/client.go b/client/client.go index 78df3f9..963d9b9 100644 --- a/client/client.go +++ b/client/client.go @@ -178,12 +178,9 @@ func (client *Client) read() (rel []byte, err error) { // out loop func (client *Client) outLoop() { - ok := true - for ok { - if job, ok := <-client.out; ok { - if err := client.write(job.Encode()); err != nil { - client.err(err) - } + for job := range client.out { + if err := client.write(job.Encode()); err != nil { + client.err(err) } } } @@ -353,7 +350,7 @@ func (client *Client) Echo(data []byte) (r []byte) { // Close func (client *Client) Close() (err error) { - close(client.in) +// close(client.in) close(client.out) close(client.echo) diff --git a/client/client_test.go b/client/client_test.go index ee1c773..e58a71d 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -11,6 +11,10 @@ func TestClientAddServer(t *testing.T) { var err error if client, err = New("127.0.0.1:4730"); err != nil { t.Error(err) + return + } + client.ErrHandler = func(e error) { + t.Log(e) } } @@ -71,7 +75,6 @@ func TestClientStatus(t *testing.T) { func TestClientClose(t *testing.T) { - return if err := client.Close(); err != nil { t.Error(err) } diff --git a/client/pool_test.go b/client/pool_test.go index eebfdbf..84afea8 100644 --- a/client/pool_test.go +++ b/client/pool_test.go @@ -1,15 +1,17 @@ package client import ( - "errors" - "testing" +// "errors" +// "testing" ) var ( pool = NewPool() ) +/* func TestPoolAdd(t *testing.T) { + return t.Log("Add servers") if err := pool.Add("127.0.0.1:4730", 1); err != nil { t.Error(err) @@ -21,7 +23,7 @@ func TestPoolAdd(t *testing.T) { t.Error(errors.New("2 servers expected")) } } -/* + func TestPoolEcho(t *testing.T) { pool.JobHandler = func(job *Job) error { echo := string(job.Data) @@ -43,10 +45,10 @@ func TestPoolDo(t *testing.T) { t.Log(handle) } } -*/ func TestPoolClose(t *testing.T) { return if err := pool.Close(); err != nil { t.Error(err) } } +*/