Documentation ¶
Index ¶
Constants ¶
const ( // MagicVersion is the cc rpc protocal version MagicVersion = uint16(0x1b01) // cmdb01 )
Variables ¶
var ( //ErrRWTimeout r/w operation timeout ErrRWTimeout = errors.New("r/w timeout") ErrPingTimeout = errors.New("Ping timeout") ErrCommandNotFount = errors.New("Command not found") ErrStreamStoped = errors.New("Stream stoped") )
Errors define
Functions ¶
This section is empty.
Types ¶
type BinaryWire ¶
type BinaryWire struct {
// contains filtered or unexported fields
}
BinaryWire implements Wire interface
func NewBinaryWire ¶
func NewBinaryWire(rwc io.ReadWriteCloser, compress string) (*BinaryWire, error)
NewBinaryWire returns a new BinaryWire
func (*BinaryWire) Read ¶
func (w *BinaryWire) Read(msg *Message) error
func (*BinaryWire) Write ¶
func (w *BinaryWire) Write(msg *Message) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client replica client
func DialHTTPPath ¶
DialHTTPPath connects to an HTTP RPC server at the specified network address and path.
func (*Client) CallStream ¶
func (c *Client) CallStream(cmd string, input interface{}) (*StreamMessage, error)
CallStream replica client
type ClientConfig ¶
type ClientConfig struct {
Address string
}
type Codec ¶
type Codec interface { Decode(data []byte, v interface{}) error Encode(v interface{}) ([]byte, error) }
Codec define a codec
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
func (*Compressor) Flush ¶
func (c *Compressor) Flush() (err error)
type HandlerFunc ¶
HandlerFunc define a HandlerFunc
type HandlerStreamFunc ¶
type HandlerStreamFunc func(Request, ServerStream) error
HandlerStreamFunc define a HandlerStreamFunc
type Message ¶
type Message struct { Data []byte // contains filtered or unexported fields }
Message define a rpc message
type MessageType ¶
type MessageType uint32
MessageType define
const ( TypeRequest MessageType = iota TypeResponse TypeStream TypeError TypeClose TypePing TypeStreamClose )
MessageType enumeration
type Request ¶
type Request interface {
Decode(value interface{}) error
}
Request define a request interface
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server define
func (*Server) Handle ¶
func (s *Server) Handle(name string, f HandlerFunc)
Handle regist new handler
func (*Server) HandleStream ¶
func (s *Server) HandleStream(name string, f HandlerStreamFunc)
HandleStream regist new stream handler
type ServerSession ¶
type ServerSession struct {
// contains filtered or unexported fields
}
ServerSession define a server session
func NewServerSession ¶
func NewServerSession(srv *Server, conn io.ReadWriteCloser, compress string) (*ServerSession, error)
NewServerSession returns a new ServerSession
type ServerStream ¶
ServerStream define interface
type StreamMessage ¶
type StreamMessage struct {
// contains filtered or unexported fields
}
StreamMessage define
func NewStreamMessage ¶
func NewStreamMessage(root *Message) *StreamMessage
NewStreamMessage returns a new StreamMessage
func (StreamMessage) Recv ¶
func (m StreamMessage) Recv(result interface{}) error
Recv receive message