Documentation ¶
Index ¶
Constants ¶
View Source
const ( // MaxHeaderSize = 10 + 10 + 4 (10 refer to binary.MaxVarintLen64) MaxHeaderSize = 24 Uint16Size = 2 Uint32Size = 4 )
Variables ¶
View Source
var ( ErrUnmarshal = errors.New("an error occurred in Unmarshal") ErrShutdown = errors.New("connection is shut down") )
Functions ¶
func NewService ¶
func NewService() *service
Types ¶
type Call ¶
type Call struct { ServiceMethod string Args Serializer Reply Serializer Error error Done chan *Call }
func NewCall ¶
func NewCall(serviceMethod string, args Serializer, reply Serializer) *Call
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(conn io.ReadWriteCloser) *Client
type ClientCodec ¶
type ClientCodec interface { WriteRequest(*RequestHeader, []byte) error ReadResponseHeader(*ResponseHeader) error ReadResponseBody() ([]byte, error) Close() error }
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) ClientCodec
type RequestHeader ¶
RequestHeader request header structure looks like: +----------+----------------+----------+ | ID | Method | Checksum| +----------+----------------+----------+ | uvarint | uvarint+string | uint32 | +----------+----------------+----------+
func (*RequestHeader) Marshal ¶
func (r *RequestHeader) Marshal() []byte
func (*RequestHeader) Unmarshal ¶
func (r *RequestHeader) Unmarshal(data []byte) error
type ResponseHeader ¶
ResponseHeader request header structure looks like: +---------+----------------+----------+ | ID | Error | Checksum| +---------+----------------+----------+ | uvarint | uvarint+string | uint32 | +---------+----------------+----------+
func (*ResponseHeader) Marshal ¶
func (r *ResponseHeader) Marshal() []byte
func (*ResponseHeader) Unmarshal ¶
func (r *ResponseHeader) Unmarshal(data []byte) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ServeCodec ¶
func (s *Server) ServeCodec(codec ServerCodec)
type ServerCodec ¶
type ServerCodec interface { ReadRequestHeader(*RequestHeader) error ReadRequestBody() ([]byte, error) WriteResponse(*ResponseHeader, []byte) error Close() error }
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser) ServerCodec
Click to show internal directories.
Click to hide internal directories.