This commit is contained in:
crusader 2017-11-30 12:36:03 +09:00
parent 6050be1f7d
commit e4d00640d2
5 changed files with 14 additions and 14 deletions

View File

@ -70,7 +70,7 @@ func (c *client) Connect() error {
logging.Logger().Panic(fmt.Sprintf("RPC Client: Initialization of client has been failed %v", err))
}
if c.conn, err = c.rwcHandler.Connect(); nil != err {
if c.conn, err = c.rwcHandler.Connect(c.ctx); nil != err {
return err
}
c.stopChan = make(chan struct{})
@ -222,7 +222,7 @@ func (c *client) handleRPC() {
<-writerDone
}
c.rwcHandler.Disconnect(c.conn)
c.rwcHandler.Disconnect(c.ctx, c.conn)
if err != nil {
//c.LogError("%s", err)

View File

@ -3,10 +3,10 @@ package client
import "git.loafle.net/commons_go/rpc/protocol"
type ClientReadWriteCloseHandler interface {
Connect() (interface{}, error)
Connect(clientCTX ClientContext) (interface{}, error)
ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error)
WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error
Disconnect(conn interface{})
Disconnect(clientCTX ClientContext, conn interface{})
Validate()
}

View File

@ -9,7 +9,7 @@ import (
type ClientReadWriteCloseHandlers struct {
}
func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) {
func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX ClientContext) (interface{}, error) {
return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement")
}
@ -21,7 +21,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext,
return fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[WriteRequest] is not implement")
}
func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) {
func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX ClientContext, conn interface{}) {
// no op
}

View File

@ -22,11 +22,11 @@ type ClientReadWriteCloseHandlers struct {
Address string
}
func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) {
func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX client.ClientContext) (interface{}, error) {
return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement")
}
func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) {
func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) {
if nil == conn {
return nil, io.EOF
}
@ -37,7 +37,7 @@ func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext,
return resCodec, err
}
func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error {
func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error {
if nil == conn {
return io.EOF
}
@ -51,7 +51,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext,
return nil
}
func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) {
func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) {
if nil == conn {
return
}

View File

@ -19,11 +19,11 @@ type ClientReadWriteCloseHandlers struct {
client.ClientReadWriteCloseHandlers
}
func (crwch *ClientReadWriteCloseHandlers) Connect() (interface{}, error) {
func (crwch *ClientReadWriteCloseHandlers) Connect(clientCTX client.ClientContext) (interface{}, error) {
return nil, fmt.Errorf("RPC Client RWC Handler: ClientHandlers method[Connect] is not implement")
}
func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) {
func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, error) {
if nil == conn {
return nil, io.EOF
}
@ -36,7 +36,7 @@ func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext,
return resCodec, err
}
func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error {
func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX client.ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error {
if nil == conn {
return io.EOF
}
@ -58,7 +58,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext,
return nil
}
func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) {
func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) {
if nil == conn {
return
}