Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrShutdown = errors.New("connection is shut down") ErrUnsupportedCodec = errors.New("unsupported Codec") )
View Source
var Codecs = map[protocol.SerializeType]Codec{ protocol.SerializeNone: &ByteCodec{}, protocol.JSON: &JSONCodec{}, protocol.ProtoBuffer: &PBCodec{}, protocol.MsgPack: &MsgpackCodec{}, }
Functions ¶
This section is empty.
Types ¶
type ByteCodec ¶
type ByteCodec struct{}
ByteCodec uses raw slice pf bytes and don't encode/decode.
type Client ¶
type ClientOption ¶
type ClientOption func(*ClientOptions)
func WithSerializeType ¶
func WithSerializeType(serializeType protocol.SerializeType) ClientOption
type ClientOptions ¶
type ClientOptions struct {
SerializeType protocol.SerializeType
}
type Codec ¶
type Codec interface { Encode(i interface{}) ([]byte, error) Decode(data []byte, i interface{}) error }
Codec defines the interface that decode/encode payload.
type Connection ¶
func (*Connection) Close ¶ added in v0.4.0
func (c *Connection) Close()
func (*Connection) ReadMessage ¶
func (*Connection) WriteMessage ¶
type JSONCodec ¶
type JSONCodec struct{}
JSONCodec uses json marshaler and unmarshaler.
type MsgpackCodec ¶
type MsgpackCodec struct{}
MsgpackCodec uses messagepack marshaller and unmarshaler.
func (MsgpackCodec) Decode ¶
func (c MsgpackCodec) Decode(data []byte, i interface{}) error
Decode decodes an object from slice of bytes.
func (MsgpackCodec) Encode ¶
func (c MsgpackCodec) Encode(i interface{}) ([]byte, error)
Encode encodes an object into slice of bytes.
type PBCodec ¶
type PBCodec struct{}
PBCodec uses protobuf marshaler and unmarshaler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(addr string, opts ...ServerOption) *Server
func (*Server) RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
type ServerError ¶
type ServerError string
ServerError represents an error that has been returned from the remote side of the RPC connection.
func (ServerError) Error ¶
func (e ServerError) Error() string
type ServerOption ¶
type ServerOption func(*ServerOptions)
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ServerOption
type ServerOptions ¶
type ServerOptions struct {
// contains filtered or unexported fields
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.