Documentation
¶
Overview ¶
Package jsonrpc2 implements a JSON-RPC 2.0 ClientCodec and ServerCodec for the net/rpc package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶
HTTPHandler returns handler for HTTP requests which will execute incoming RPC using srv. If srv is nil then use rpc.DefaultServer.
Specification: http://www.simple-is-better.org/json-rpc/transport_http.html
- Pipelined Requests/Responses not supported.
- GET Request not supported.
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
NewClientCodec returns a new rpc.ClientCodec using JSON-RPC 2.0 on conn.
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser, srv *rpc.Server) rpc.ServerCodec
NewServerCodec returns a new rpc.ServerCodec using JSON-RPC 2.0 on conn, which will use srv to execute batch requests.
If srv is nil then rpc.DefaultServer will be used.
func ServeConn ¶
func ServeConn(conn io.ReadWriteCloser)
ServeConn runs the JSON-RPC 2.0 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 BatchArg ¶
type BatchArg struct {
// contains filtered or unexported fields
}
BatchArg is a param for internal RPC JSONRPC2.Batch.
type Client ¶
Client represents a JSON RPC 2.0 Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously.
It also provides all methods of net/rpc Client.
func NewClient ¶
func NewClient(conn io.ReadWriteCloser) *Client
NewClient returns a new Client to handle requests to the set of services at the other end of the connection.
func NewHTTPClient ¶
NewHTTPClient returns a new Client to handle requests to the set of services at the given url.
func (Client) GetUnhandledChannel ¶
func (c Client) GetUnhandledChannel() chan interface{}
type Error ¶
type Error struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
Error represent JSON-RPC 2.0 "Error object".
func ServerError ¶
ServerError convert errors returned by Client.Call() into Error. User should check for rpc.ErrShutdown and io.ErrUnexpectedEOF before calling ServerError.