Versions in this module Expand all Collapse all v1 v1.0.1 Apr 12, 2022 Changes in this version + const DefaultRespQueueSize + const DefaultWriteAttemptTimes + var ErrServerStopped = fmt.Errorf("server stopped") + func NewContext() *routeContext + func SetLogger(lg Logger) + type Codec interface + Decode func(data []byte, v interface{}) error + Encode func(v interface{}) ([]byte, error) + type Context interface + Bind func(v interface{}) error + Copy func() Context + Get func(key string) (value interface{}, exists bool) + MustSetRequest func(id, data interface{}) Context + MustSetResponse func(id, data interface{}) Context + Remove func(key string) + Request func() *message.Entry + Response func() *message.Entry + Send func() bool + SendTo func(session Session) bool + Session func() Session + Set func(key string, value interface{}) + SetRequest func(id, data interface{}) error + SetRequestMessage func(entry *message.Entry) Context + SetResponse func(id, data interface{}) error + SetResponseMessage func(entry *message.Entry) Context + SetSession func(sess Session) Context + WithContext func(ctx context.Context) Context + type DefaultLogger struct + func (d *DefaultLogger) Errorf(format string, args ...interface{}) + func (d *DefaultLogger) Tracef(format string, args ...interface{}) + type DefaultPacker struct + MaxDataSize int + func NewDefaultPacker() *DefaultPacker + func (d *DefaultPacker) Pack(entry *message.Entry) ([]byte, error) + func (d *DefaultPacker) Unpack(reader io.Reader) (*message.Entry, error) + type HandlerFunc func(ctx Context) + type JsonCodec struct + func (c *JsonCodec) Decode(data []byte, v interface{}) error + func (c *JsonCodec) Encode(v interface{}) ([]byte, error) + type Logger interface + Errorf func(format string, args ...interface{}) + Tracef func(format string, args ...interface{}) + var Log Logger = newMuteLogger() + type MiddlewareFunc func(next HandlerFunc) HandlerFunc + type MsgpackCodec struct + func (m *MsgpackCodec) Decode(data []byte, v interface{}) error + func (m *MsgpackCodec) Encode(v interface{}) ([]byte, error) + type Packer interface + Pack func(entry *message.Entry) ([]byte, error) + Unpack func(reader io.Reader) (*message.Entry, error) + type ProtobufCodec struct + func (p *ProtobufCodec) Decode(data []byte, v interface{}) error + func (p *ProtobufCodec) Encode(v interface{}) ([]byte, error) + type Router struct + type Server struct + Codec Codec + Listener net.Listener + OnSessionClose func(sess Session) + OnSessionCreate func(sess Session) + Packer Packer + func NewServer(opt *ServerOption) *Server + func (s *Server) AddRoute(msgID interface{}, handler HandlerFunc, middlewares ...MiddlewareFunc) + func (s *Server) NotFoundHandler(handler HandlerFunc) + func (s *Server) Serve(addr string) error + func (s *Server) ServeTLS(addr string, config *tls.Config) error + func (s *Server) Stop() error + func (s *Server) Use(middlewares ...MiddlewareFunc) + type ServerOption struct + AsyncRouter bool + Codec Codec + DoNotPrintRoutes bool + Packer Packer + ReadTimeout time.Duration + RespQueueSize int + SocketReadBufferSize int + SocketSendDelay bool + SocketWriteBufferSize int + WriteAttemptTimes int + WriteTimeout time.Duration + type Session interface + AllocateContext func() Context + Close func() + Codec func() Codec + ID func() interface{} + Send func(ctx Context) bool + SetID func(id interface{})