Documentation
¶
Index ¶
- Variables
- func DecodeGeneral(r io.Reader, msg proto.Message, tag string) (err error)
- func Send(c io.Writer, msg *RpcMessage) error
- func Serve(l net.Listener)
- func ServeConn(conn io.ReadWriteCloser)
- type ClientCodec
- type ErrorCode
- type MessageType
- type RpcMessage
- func (m *RpcMessage) GetError() ErrorCode
- func (m *RpcMessage) GetId() uint64
- func (m *RpcMessage) GetMethod() string
- func (m *RpcMessage) GetRequest() []byte
- func (m *RpcMessage) GetResponse() []byte
- func (m *RpcMessage) GetService() string
- func (m *RpcMessage) GetType() MessageType
- func (*RpcMessage) ProtoMessage()
- func (m *RpcMessage) Reset()
- func (m *RpcMessage) String() string
- type ServerCodec
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorCode_name = map[int32]string{
0: "NO_ERROR",
1: "WRONG_PROTO",
2: "NO_SERVICE",
3: "NO_METHOD",
4: "INVALID_REQUEST",
5: "INVALID_RESPONSE",
}
View Source
var ErrorCode_value = map[string]int32{
"NO_ERROR": 0,
"WRONG_PROTO": 1,
"NO_SERVICE": 2,
"NO_METHOD": 3,
"INVALID_REQUEST": 4,
"INVALID_RESPONSE": 5,
}
View Source
var MessageType_name = map[int32]string{
1: "REQUEST",
2: "RESPONSE",
3: "ERROR",
}
View Source
var MessageType_value = map[string]int32{
"REQUEST": 1,
"RESPONSE": 2,
"ERROR": 3,
}
Functions ¶
func ServeConn ¶
func ServeConn(conn io.ReadWriteCloser)
Types ¶
type ClientCodec ¶
type ClientCodec struct {
// contains filtered or unexported fields
}
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) *ClientCodec
func (*ClientCodec) Close ¶
func (c *ClientCodec) Close() error
func (*ClientCodec) ReadResponseBody ¶
func (c *ClientCodec) ReadResponseBody(body interface{}) (err error)
FIXME: merge dup code with ServerCodec.ReadRequestBody()
func (*ClientCodec) ReadResponseHeader ¶
func (c *ClientCodec) ReadResponseHeader(r *rpc.Response) (err error)
func (*ClientCodec) WriteRequest ¶
func (c *ClientCodec) WriteRequest(r *rpc.Request, body interface{}) error
type ErrorCode ¶
type ErrorCode int32
func (ErrorCode) MarshalJSON ¶
func (*ErrorCode) UnmarshalJSON ¶
type MessageType ¶
type MessageType int32
const ( MessageType_REQUEST MessageType = 1 MessageType_RESPONSE MessageType = 2 MessageType_ERROR MessageType = 3 )
func (MessageType) Enum ¶
func (x MessageType) Enum() *MessageType
func (MessageType) MarshalJSON ¶
func (x MessageType) MarshalJSON() ([]byte, error)
func (MessageType) String ¶
func (x MessageType) String() string
func (*MessageType) UnmarshalJSON ¶
func (x *MessageType) UnmarshalJSON(data []byte) error
type RpcMessage ¶
type RpcMessage struct {
Type *MessageType `protobuf:"varint,1,req,name=type,enum=muduo.net.MessageType" json:"type,omitempty"`
Id *uint64 `protobuf:"fixed64,2,req,name=id" json:"id,omitempty"`
Service *string `protobuf:"bytes,3,opt,name=service" json:"service,omitempty"`
Method *string `protobuf:"bytes,4,opt,name=method" json:"method,omitempty"`
Request []byte `protobuf:"bytes,5,opt,name=request" json:"request,omitempty"`
Response []byte `protobuf:"bytes,6,opt,name=response" json:"response,omitempty"`
Error *ErrorCode `protobuf:"varint,7,opt,name=error,enum=muduo.net.ErrorCode" json:"error,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (*RpcMessage) GetError ¶
func (m *RpcMessage) GetError() ErrorCode
func (*RpcMessage) GetId ¶
func (m *RpcMessage) GetId() uint64
func (*RpcMessage) GetMethod ¶
func (m *RpcMessage) GetMethod() string
func (*RpcMessage) GetRequest ¶
func (m *RpcMessage) GetRequest() []byte
func (*RpcMessage) GetResponse ¶
func (m *RpcMessage) GetResponse() []byte
func (*RpcMessage) GetService ¶
func (m *RpcMessage) GetService() string
func (*RpcMessage) GetType ¶
func (m *RpcMessage) GetType() MessageType
func (*RpcMessage) ProtoMessage ¶
func (*RpcMessage) ProtoMessage()
func (*RpcMessage) Reset ¶
func (m *RpcMessage) Reset()
func (*RpcMessage) String ¶
func (m *RpcMessage) String() string
type ServerCodec ¶
type ServerCodec struct {
// contains filtered or unexported fields
}
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser) *ServerCodec
func (*ServerCodec) Close ¶
func (c *ServerCodec) Close() error
func (*ServerCodec) ReadRequestBody ¶
func (c *ServerCodec) ReadRequestBody(body interface{}) (err error)
func (*ServerCodec) ReadRequestHeader ¶
func (c *ServerCodec) ReadRequestHeader(r *rpc.Request) (err error)
func (*ServerCodec) WriteResponse ¶
func (c *ServerCodec) WriteResponse(r *rpc.Response, body interface{}) error
Click to show internal directories.
Click to hide internal directories.