This commit is contained in:
crusader 2017-11-01 12:40:26 +09:00
parent b4b379c891
commit 78c2f69893
3 changed files with 10 additions and 10 deletions

View File

@ -2,8 +2,8 @@ package client
import (
"fmt"
"io"
"log"
"net"
"runtime"
"sync"
"sync/atomic"
@ -31,7 +31,7 @@ type Client interface {
type client struct {
ch ClientHandler
rwc io.ReadWriteCloser
conn net.Conn
pendingRequestsCount uint32
pendingRequests map[interface{}]*CallState
@ -51,7 +51,7 @@ func (c *client) Connect() error {
panic("RPC Client: the given client is already started. Call Client.Stop() before calling Client.Start() again!")
}
if c.rwc, err = c.ch.Connect(); nil != err {
if c.conn, err = c.ch.Connect(); nil != err {
return err
}
c.stopChan = make(chan struct{})
@ -187,7 +187,7 @@ func (c *client) handleRPC() {
<-writerDone
}
c.rwc.Close()
c.conn.Close()
if err != nil {
//c.LogError("%s", err)
@ -258,7 +258,7 @@ func (c *client) rpcWriter(stopChan <-chan struct{}, writerDone chan<- error) {
releaseCallState(cs)
}
if err = c.ch.GetCodec().Write(c.rwc, cs.Method, cs.Args, cs.ID); nil != err {
if err = c.ch.GetCodec().Write(c.conn, cs.Method, cs.Args, cs.ID); nil != err {
err = fmt.Errorf("Client: Cannot send request to wire: [%s]", err)
return
}
@ -277,7 +277,7 @@ func (c *client) rpcReader(readerDone chan<- error) {
}()
for {
crn, err := c.ch.GetCodec().NewResponseOrNotify(c.rwc)
crn, err := c.ch.GetCodec().NewResponseOrNotify(c.conn)
if nil != err {
err = fmt.Errorf("Client: Cannot decode response or notify: [%s]", err)
return

View File

@ -1,7 +1,7 @@
package client
import (
"io"
"net"
"time"
"git.loafle.net/commons_go/rpc"
@ -9,7 +9,7 @@ import (
)
type ClientHandler interface {
Connect() (io.ReadWriteCloser, error)
Connect() (net.Conn, error)
GetCodec() protocol.ClientCodec
GetRPCRegistry() rpc.Registry

View File

@ -2,7 +2,7 @@ package client
import (
"errors"
"io"
"net"
"sync"
"time"
@ -30,7 +30,7 @@ type ClientHandlers struct {
requestIDMtx sync.Mutex
}
func (ch *ClientHandlers) Connect() (io.ReadWriteCloser, error) {
func (ch *ClientHandlers) Connect() (net.Conn, error) {
return nil, errors.New("RPC Client: ClientHandlers method[Connect] is not implement")
}