Documentation ¶
Overview ¶
Package msgpackrpc implements a MessagePack-RPC ClientCodec and ServerCodec for the rpc package, using the same API as the Go standard library for jsonrpc.
Index ¶
- func CallWithCodec(cc rpc.ClientCodec, method string, args interface{}, resp interface{}) error
- func Dial(network, address string) (*rpc.Client, error)
- func NewClient(conn io.ReadWriteCloser) *rpc.Client
- func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
- func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec
- func ServeConn(conn io.ReadWriteCloser)
- type MsgpackCodec
- func (cc *MsgpackCodec) Close() error
- func (cc *MsgpackCodec) ReadRequestBody(out interface{}) error
- func (cc *MsgpackCodec) ReadRequestHeader(r *rpc.Request) error
- func (cc *MsgpackCodec) ReadResponseBody(out interface{}) error
- func (cc *MsgpackCodec) ReadResponseHeader(r *rpc.Response) error
- func (cc *MsgpackCodec) WriteRequest(r *rpc.Request, body interface{}) error
- func (cc *MsgpackCodec) WriteResponse(r *rpc.Response, body interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallWithCodec ¶
func CallWithCodec(cc rpc.ClientCodec, method string, args interface{}, resp interface{}) error
CallWithCodec is used to perform the same actions as rpc.Client.Call but in a much cheaper way. It assumes the underlying connection is not being shared with multiple concurrent RPCs. The request/response must be syncronous.
func NewClient ¶
func NewClient(conn io.ReadWriteCloser) *rpc.Client
NewClient returns a new rpc.Client to handle requests to the set of services at the other end of the connection.
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
NewClientCodec returns a new rpc.ClientCodec using MessagePack-RPC on conn.
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec
NewServerCodec returns a new rpc.ServerCodec using MessagePack-RPC on conn.
func ServeConn ¶
func ServeConn(conn io.ReadWriteCloser)
ServeConn runs the MessagePack-RPC server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement.
Types ¶
type MsgpackCodec ¶
type MsgpackCodec struct {
// contains filtered or unexported fields
}
MsgpackCodec implements the rpc.ClientCodec and rpc.ServerCodec using the msgpack encoding
func NewCodec ¶
func NewCodec(bufReads, bufWrites bool, conn io.ReadWriteCloser) *MsgpackCodec
NewCodec returns a MsgpackCodec that can be used as either a Client or Server rpc Codec using a default handle. It also provides controls for enabling and disabling buffering for both reads and writes.
func NewCodecFromHandle ¶
func NewCodecFromHandle(bufReads, bufWrites bool, conn io.ReadWriteCloser, h *codec.MsgpackHandle) *MsgpackCodec
NewCodecFromHandle returns a MsgpackCodec that can be used as either a Client or Server rpc Codec using the passed handle. It also provides controls for enabling and disabling buffering for both reads and writes.
func (*MsgpackCodec) Close ¶
func (cc *MsgpackCodec) Close() error
func (*MsgpackCodec) ReadRequestBody ¶
func (cc *MsgpackCodec) ReadRequestBody(out interface{}) error
func (*MsgpackCodec) ReadRequestHeader ¶
func (cc *MsgpackCodec) ReadRequestHeader(r *rpc.Request) error
func (*MsgpackCodec) ReadResponseBody ¶
func (cc *MsgpackCodec) ReadResponseBody(out interface{}) error
func (*MsgpackCodec) ReadResponseHeader ¶
func (cc *MsgpackCodec) ReadResponseHeader(r *rpc.Response) error
func (*MsgpackCodec) WriteRequest ¶
func (cc *MsgpackCodec) WriteRequest(r *rpc.Request, body interface{}) error
func (*MsgpackCodec) WriteResponse ¶
func (cc *MsgpackCodec) WriteResponse(r *rpc.Response, body interface{}) error