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 jsoncore.
Index ¶
- func CallWithCodec(ctx context.Context, cc core.ClientCodec, method string, args interface{}, ...) error
- func Dial(network, address string) (*core.Client, error)
- func NewClient(conn io.ReadWriteCloser) *core.Client
- func NewClientCodec(conn io.ReadWriteCloser) core.ClientCodec
- func NewServerCodec(conn io.ReadWriteCloser) core.ServerCodec
- func ServeConn(conn io.ReadWriteCloser)
- type MsgpackCodec
- func (cc *MsgpackCodec) Close() error
- func (cc *MsgpackCodec) ReadRequestBody(ctx context.Context, out interface{}) error
- func (cc *MsgpackCodec) ReadRequestHeader(ctx context.Context, r *core.Request) error
- func (cc *MsgpackCodec) ReadResponseBody(out interface{}) error
- func (cc *MsgpackCodec) ReadResponseHeader(r *core.Response) error
- func (cc *MsgpackCodec) WriteRequest(ctx context.Context, r *core.Request, body interface{}) error
- func (cc *MsgpackCodec) WriteResponse(ctx context.Context, r *core.Response, body interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallWithCodec ¶
func CallWithCodec(ctx context.Context, cc core.ClientCodec, method string, args interface{}, resp interface{}) error
CallWithCodec is used to perform the same actions as core.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) *core.Client
NewClient returns a new core.Client to handle requests to the set of services at the other end of the connection.
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) core.ClientCodec
NewClientCodec returns a new core.ClientCodec using MessagePack-RPC on conn.
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser) core.ServerCodec
NewServerCodec returns a new core.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 core.ClientCodec and core.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(ctx context.Context, out interface{}) error
func (*MsgpackCodec) ReadRequestHeader ¶
func (*MsgpackCodec) ReadResponseBody ¶
func (cc *MsgpackCodec) ReadResponseBody(out interface{}) error
func (*MsgpackCodec) ReadResponseHeader ¶
func (cc *MsgpackCodec) ReadResponseHeader(r *core.Response) error