msgpackrpc

package module
v0.0.0-...-27a961a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 9 Imported by: 0

README

net-rpc-msgpackrpc

This library provides the same functions as net/rpc/jsonrpc but for communicating with MessagePack instead. The library is modeled directly after the Go standard library so it should be easy to use and obvious.

See the GoDoc for API documentation.

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

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 Dial

func Dial(network, address string) (*rpc.Client, error)

Dial connects to a MessagePack-RPC server at the specified network address.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL