Versions in this module Expand all Collapse all v2 v2.0.2 Jul 7, 2019 v2.0.0 Jul 7, 2019 Changes in this version + const ProtoJSON + const ProtoRocketMQ + const StateClosing + const StateConnected + const StateDisconnected + var ErrBadContent = errors.New("bad content") + var ErrDisconnected = errors.New("disconnected") + var ErrNeedContent = errors.New("need content") + func ReadPacket(r io.Reader) ([]byte, error) + type ChannelConfig struct + type ChannelContext struct + Address string + Conn net.Conn + func (ctx *ChannelContext) String() string + type ChannelState int + type Client interface + RequestAsync func(addr string, cmd *Command, timeout time.Duration, ...) error + RequestOneway func(addr string, cmd *Command) error + RequestSync func(addr string, cmd *Command, timeout time.Duration) (*Command, error) + Shutdown func() + Start func() error + func NewClient(conf ClientConfig, rp func(*ChannelContext, *Command) bool, logger log.Logger) (Client, error) + type ClientConfig struct + DialTimeout time.Duration + ReadTimeout time.Duration + WriteTimeout time.Duration + type Code int16 + func Int16ToCode(code int16) Code + func (c *Code) UnmarshalJSON(b []byte) error + func (c Code) ToInt16() int16 + type Command struct + Body []byte + Code Code + ExtFields map[string]string + Flag int32 + Language LanguageCode + Opaque int32 + Remark string + Version int16 + func NewCommand(code Code, header HeaderOfMapper) *Command + func NewCommandWithBody(code Code, header HeaderOfMapper, body []byte) *Command + func (cmd *Command) Decode(buf []byte) (interface{}, error) + func (cmd *Command) Encode(interface{}) ([]byte, error) + func (cmd *Command) ID() int64 + func (cmd *Command) IsOneway() bool + func (cmd *Command) MarkResponse() + func (cmd *Command) Read(r io.Reader) ([]byte, error) + func (cmd *Command) String() string + type Decoder interface + Decode func([]byte) (*Command, error) + type DecoderFunc func([]byte) (*Command, error) + func (f DecoderFunc) Decode(d []byte) (*Command, error) + type Encoder interface + Encode func(*Command) ([]byte, error) + type EncoderFunc func(*Command) ([]byte, error) + func (f EncoderFunc) Encode(cmd *Command) ([]byte, error) + type FakeClient struct + func (m *FakeClient) RequestAsync(addr string, cmd *Command, timeout time.Duration, ...) error + func (m *FakeClient) RequestOneway(addr string, cmd *Command) error + func (m *FakeClient) RequestSync(addr string, cmd *Command, timeout time.Duration) (*Command, error) + func (m *FakeClient) Shutdown() + func (m *FakeClient) Start() error + type Handler interface + OnActive func(ctx *ChannelContext) + OnClose func(ctx *ChannelContext) + OnDeactive func(ctx *ChannelContext) + OnError func(ctx *ChannelContext, err error) + OnMessage func(ctx *ChannelContext, cmd *Command) + type HeaderOfMapper interface + ToMap func() map[string]string + type LanguageCode int8 + func (lc *LanguageCode) UnmarshalJSON(b []byte) error + func (lc LanguageCode) String() string + func (lc LanguageCode) ToInt8() int8 + type PacketReader interface + Read func(io.Reader) ([]byte, error) + type PacketReaderFunc func(io.Reader) ([]byte, error) + func (f PacketReaderFunc) Read(r io.Reader) ([]byte, error)