ing
This commit is contained in:
parent
6050be1f7d
commit
e4d00640d2
|
@ -70,7 +70,7 @@ func (c *client) Connect() error {
|
||||||
logging.Logger().Panic(fmt.Sprintf("RPC Client: Initialization of client has been failed %v", err))
|
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
|
return err
|
||||||
}
|
}
|
||||||
c.stopChan = make(chan struct{})
|
c.stopChan = make(chan struct{})
|
||||||
|
@ -222,7 +222,7 @@ func (c *client) handleRPC() {
|
||||||
<-writerDone
|
<-writerDone
|
||||||
}
|
}
|
||||||
|
|
||||||
c.rwcHandler.Disconnect(c.conn)
|
c.rwcHandler.Disconnect(c.ctx, c.conn)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//c.LogError("%s", err)
|
//c.LogError("%s", err)
|
||||||
|
|
|
@ -3,10 +3,10 @@ package client
|
||||||
import "git.loafle.net/commons_go/rpc/protocol"
|
import "git.loafle.net/commons_go/rpc/protocol"
|
||||||
|
|
||||||
type ClientReadWriteCloseHandler interface {
|
type ClientReadWriteCloseHandler interface {
|
||||||
Connect() (interface{}, error)
|
Connect(clientCTX ClientContext) (interface{}, error)
|
||||||
ReadResponse(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}) (protocol.ClientResponseCodec, 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
|
WriteRequest(clientCTX ClientContext, codec protocol.ClientCodec, conn interface{}, method string, params interface{}, id interface{}) error
|
||||||
Disconnect(conn interface{})
|
Disconnect(clientCTX ClientContext, conn interface{})
|
||||||
|
|
||||||
Validate()
|
Validate()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
type ClientReadWriteCloseHandlers struct {
|
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")
|
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")
|
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
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,11 @@ type ClientReadWriteCloseHandlers struct {
|
||||||
Address string
|
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")
|
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 {
|
if nil == conn {
|
||||||
return nil, io.EOF
|
return nil, io.EOF
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext,
|
||||||
return resCodec, err
|
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 {
|
if nil == conn {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) {
|
func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) {
|
||||||
if nil == conn {
|
if nil == conn {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@ type ClientReadWriteCloseHandlers struct {
|
||||||
client.ClientReadWriteCloseHandlers
|
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")
|
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 {
|
if nil == conn {
|
||||||
return nil, io.EOF
|
return nil, io.EOF
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func (crwch *ClientReadWriteCloseHandlers) ReadResponse(clientCTX ClientContext,
|
||||||
return resCodec, err
|
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 {
|
if nil == conn {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func (crwch *ClientReadWriteCloseHandlers) WriteRequest(clientCTX ClientContext,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crwch *ClientReadWriteCloseHandlers) Disconnect(conn interface{}) {
|
func (crwch *ClientReadWriteCloseHandlers) Disconnect(clientCTX client.ClientContext, conn interface{}) {
|
||||||
if nil == conn {
|
if nil == conn {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user