Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterError ¶
func RegisterError(err error)
RegisterError allows to register an error like io.EOF, which then will be returned by its name from Client.Call as opError
Types ¶
type BufCollector ¶
type BufCollector interface { // Collect stores the buf into the pool, to be reused for future needs Collect(buf []byte) }
BufCollector allows to collect byte buffers that are not going to be used anymore. The buffers could be reused by Client or the Server later for processing requests and responses. Must be used with extra care
type Client ¶
type Client interface { io.Closer BufCollector // Call makes a call to the server. Expects function Id, the message, which has to be sent. The Call will block the // calling go-routine until ctx is done, a response is received or an error happens related to the Call processing. // It returns response body, opErr contains the function execution error, which doesn't relate to the connection. // The err contains an error related to the call execution (connection problems etc.) Call(ctx context.Context, funcId int, msg xbinary.Writable) (respBody []byte, opErr error, err error) }
Client allows to make remote calls to the server
func NewClient ¶
func NewClient(rwc io.ReadWriteCloser) Client
NewClient creates new Client object for building RPC over rwc
type OnClientReqFunc ¶
type OnClientReqFunc func(reqId int32, reqBody []byte, sc *ServerConn)
OnClientReqFunc represents a server endpoint for handling a client call. The function will be selected by Server by the funcId received in the request.
type Server ¶
type Server interface { io.Closer // Register adds a callback which will be called by the funcId Register(funcId int, cb OnClientReqFunc) error // Serve is called for sc - the server code which will be served until the codec is closed or the server is // shutdown Serve(connId string, rwc io.ReadWriteCloser) error }
Server supports server implementation for client requests handling.
type ServerConn ¶
type ServerConn struct {
// contains filtered or unexported fields
}
func (*ServerConn) Close ¶
func (sc *ServerConn) Close() error
func (*ServerConn) Collect ¶
func (sc *ServerConn) Collect(buf []byte)
func (*ServerConn) SendResponse ¶
func (sc *ServerConn) SendResponse(reqId int32, opErr error, msg xbinary.Writable)
SendResponse allows to send the response by the request id