Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONClientEncoder ¶
type JSONClientEncoder struct{}
JSONClientEncoder is RPCClientEncoder using json encoding.
func (JSONClientEncoder) DecodeReply ¶
func (e JSONClientEncoder) DecodeReply(data []byte, reply *RPCReply) error
DecodeReply implements RPCClientEncoder interface.
func (JSONClientEncoder) EncodeRequest ¶
func (e JSONClientEncoder) EncodeRequest(req *RPCRequest) ([]byte, error)
EncodeRequest implements RPCClientEncoder interface.
type JSONReply ¶
type JSONReply struct { Result json.RawMessage `json:"result,omitempty"` Error string `json:"error,omitempty"` }
JSONReply is reply of a RPC call encoded by json.
type JSONRequest ¶
type JSONRequest struct { Param json.RawMessage `json:"param"` MetaData nproto.MetaData `json:"metaData,omitempty"` Timeout int64 `json:"timeout,omitempty"` }
JSONRequest is request of a RPC call encoded by json.
type JSONServerEncoder ¶
type JSONServerEncoder struct{}
JSONServerEncoder is RPCServerEncoder using json encoding.
func (JSONServerEncoder) DecodeRequest ¶
func (e JSONServerEncoder) DecodeRequest(data []byte, req *RPCRequest) error
DecodeRequest implements RPCServerEncoder interface.
func (JSONServerEncoder) EncodeReply ¶
func (e JSONServerEncoder) EncodeReply(reply *RPCReply) ([]byte, error)
EncodeReply implements RPCServerEncoder interface.
type PBClientEncoder ¶
type PBClientEncoder struct{}
PBClientEncoder is RPCClientEncoder using protobuf encoding.
func (PBClientEncoder) DecodeReply ¶
func (e PBClientEncoder) DecodeReply(data []byte, reply *RPCReply) error
DecodeReply implements RPCClientEncoder interface.
func (PBClientEncoder) EncodeRequest ¶
func (e PBClientEncoder) EncodeRequest(req *RPCRequest) ([]byte, error)
EncodeRequest implements RPCClientEncoder interface.
type PBServerEncoder ¶
type PBServerEncoder struct{}
PBServerEncoder is RPCServerEncoder using protobuf encoding.
func (PBServerEncoder) DecodeRequest ¶
func (e PBServerEncoder) DecodeRequest(data []byte, req *RPCRequest) error
DecodeRequest implements RPCServerEncoder interface.
func (PBServerEncoder) EncodeReply ¶
func (e PBServerEncoder) EncodeReply(reply *RPCReply) ([]byte, error)
EncodeReply implements RPCServerEncoder interface.
type RPCClientEncoder ¶
type RPCClientEncoder interface { // EncodeRequest encodes request to data. EncodeRequest(req *RPCRequest) ([]byte, error) // DecodeReply decodes reply from data. DecodeReply(data []byte, reply *RPCReply) error }
RPCClientEncoder is the client-side encoder.
type RPCReply ¶
type RPCReply struct { // Result is the normal result of this rpc. Must set to nil if there is an error. // NOTE: Must filled with an empty proto message before decoding. // Otherwise the encoder can't determine the which type to decode. Result proto.Message // Error is the error result of this rpc. Must set to nil if there is no error. Error error }
RPCReply is the reply of an rpc.
type RPCRequest ¶
type RPCRequest struct { // Param is the parameter of this rpc. // NOTE: Must filled with an empty proto message before decoding. // Otherwise the encoder can't determine which type to decode. Param proto.Message // MD is a dict containing extra context information. Maybe nil. MD nproto.MD // Timeout is timeout of this RPC if > 0. Timeout time.Duration }
RPCRequest is the request of an rpc.
type RPCServerEncoder ¶
type RPCServerEncoder interface { // DecodeRequest decodes request from data. DecodeRequest(data []byte, req *RPCRequest) error // EncodeReply encodes reply to data. EncodeReply(reply *RPCReply) ([]byte, error) }
RPCServerEncoder is the server-side encoder.