Versions in this module Expand all Collapse all v1 v1.0.2 Dec 3, 2022 Changes in this version + const DEFAULT_READ_TIMEOUT + const DEFAULT_WRITE_TIMEOUT + const GRACEFUL_ENVIRON_KEY + const GRACEFUL_ENVIRON_STRING + func GbToUtf8(s []byte) ([]byte, error) + func Utf8ToGb(s []byte) ([]byte, error) + type Listener struct + func ListenTCP(nett string, laddr *net.TCPAddr, server *Server) (*Listener, error) + func NewListener(listener *net.TCPListener, server *Server) *Listener + func (l *Listener) Accept() (*net.TCPConn, error) + func (l *Listener) GetFd() (uintptr, error) + func (l *Listener) GetWg() *sync.WaitGroup + func (l *Listener) Wait() type Options + PidFilePath string v1.0.1 Nov 26, 2022 Changes in this version + const BLUE + const DEV + const ERROR + const GREEN + const INFO + const MAGENTA + const PRODUCTION + const RED + const SUCCESS + const TRAC + const WARN + const YELLOW + func AddressToClientId(connection IConnection) string + func CloseClient(request IRequest, clientId string, data []byte) error + func IsOnLine(request IRequest, clientId string) bool + func SendToClient(request IRequest, clientId string, data []byte) error + type Connection struct + Conn *net.TCPConn + ConnID uint32 + ExitChan chan bool + Handles IHandler + func (c *Connection) DelProperty(key string) + func (c *Connection) GetConn() *net.TCPConn + func (c *Connection) GetID() uint32 + func (c *Connection) GetProperty(key string) (interface{}, error) + func (c *Connection) GetServer() IServer + func (c *Connection) RemoteAddr() net.Addr + func (c *Connection) Send(data []byte) error + func (c *Connection) SetPackProto(proto IPack) + func (c *Connection) SetProperty(key string, val interface{}) + func (c *Connection) SetProtoPack(proto IPack) + func (c *Connection) Start() + func (c *Connection) StartReader() + func (c *Connection) StartWriter() + func (c *Connection) Stop() + type HLog struct + var Log *HLog + func NewLog() *HLog + func NewLogWithModel(model string) *HLog + func (l *HLog) Error(format string, args ...interface{}) + func (l *HLog) Info(format string, args ...interface{}) + func (l *HLog) Success(format string, args ...interface{}) + func (l *HLog) Trace(format string, args ...interface{}) + func (l *HLog) Warning(format string, args ...interface{}) + type HandleFunc func(*net.TCPConn, []byte, int) error + type Handler struct + Middlewares []HandlerFunc + func NewHandler() *Handler + func (h *Handler) Abort() + func (h *Handler) After(rf HandlerFunc) + func (h *Handler) Before(rf HandlerFunc) + func (h *Handler) RunHandler(request IRequest) + func (h *Handler) RunWorkPool() + func (h *Handler) SendToTasks(rq IRequest) + func (h *Handler) SetEventHandle(event IEvent) + func (h *Handler) SetWorkPoolSize(size uint32) + func (h *Handler) Use(rf HandlerFunc) + type HandlerFunc func(request IRequest) + type IConnection interface + DelProperty func(key string) + GetConn func() *net.TCPConn + GetID func() uint32 + GetProperty func(key string) (interface{}, error) + GetServer func() IServer + RemoteAddr func() net.Addr + Send func(data []byte) error + SetProperty func(key string, val interface{}) + SetProtoPack func(IPack) + Start func() + Stop func() + func NewConnection(server IServer, conn *net.TCPConn, id uint32, handler IHandler) IConnection + type IEvent interface + OnClose func(IConnection, string) + OnConnect func(IConnection, string) + OnMessage func(IRequest) + OnWorkerStart func() + type IHandler interface + Abort func() + After func(HandlerFunc) + Before func(HandlerFunc) + RunHandler func(request IRequest) + RunWorkPool func() + SendToTasks func(rq IRequest) + SetEventHandle func(IEvent) + SetWorkPoolSize func(size uint32) + Use func(HandlerFunc) + type IManager interface + Add func(con IConnection) + Clear func() + Del func(con IConnection) + Get func(id uint32) (IConnection, error) + Num func() int + func NewManager() IManager + type IMessage interface + GetData func() []byte + GetId func() uint32 + GetLen func() uint32 + SetData func([]byte) + SetId func(uint32) + SetLen func(uint32) + type IPack interface + Input func(string) int + Pack func([]byte) []byte + UnPack func([]byte) []byte + type IRequest interface + GetClientId func() string + GetConnection func() IConnection + GetData func() []byte + GetID func() uint32 + GetLen func() uint32 + GetWorkId func() uint32 + SetWorkId func(uint32) + func NewRequest(con IConnection, msg IMessage, rid *uint32, clientId string) IRequest + type IServer interface + Abort func() + After func(HandlerFunc) + Before func(HandlerFunc) + GetManager func() IManager + GetRid func() *uint32 + OnStart func(hookHandler) + OnStop func(hookHandler) + OverLoad func(overloadHandler) + Run func() + SetEventHandle func(IEvent) + SetMaxCon func(uint32) + SetWorkPoolSize func(uint32) + Stop func() + Use func(HandlerFunc) + type Manager struct + func (m *Manager) Add(con IConnection) + func (m *Manager) Clear() + func (m *Manager) Del(con IConnection) + func (m *Manager) Get(id uint32) (IConnection, error) + func (m *Manager) Num() int + type Message struct + Data []byte + Id uint32 + Length uint32 + func (msg *Message) GetData() []byte + func (msg *Message) GetId() uint32 + func (msg *Message) GetLen() uint32 + func (msg *Message) SetData(data []byte) + func (msg *Message) SetId(id uint32) + func (msg *Message) SetLen(len uint32) + type Options struct + IP string + MaxConnNum uint32 + MaxConnections uint32 + Model string + Port int + WorkPool uint32 + type Request struct + func (r *Request) GetClientId() string + func (r *Request) GetConnection() IConnection + func (r *Request) GetData() []byte + func (r *Request) GetID() uint32 + func (r *Request) GetLen() uint32 + func (r *Request) GetWorkId() uint32 + func (r *Request) SetWorkId(workId uint32) + type Server struct + Conn *net.TCPListener + Handles *Handler + IP string + IPVersion string + Port int + Version string + func NewServer() *Server + func NewServerWithOptions(options *Options) *Server + func (s *Server) Abort() + func (s *Server) After(rf HandlerFunc) + func (s *Server) Before(rf HandlerFunc) + func (s *Server) GetManager() IManager + func (s *Server) GetRid() *uint32 + func (s *Server) OnStart(hook hookHandler) + func (s *Server) OnStop(c hookHandler) + func (s *Server) OverLoad(o overloadHandler) + func (s *Server) Run() + func (s *Server) SetConfig(conf *viper.Viper) + func (s *Server) SetEventHandle(event IEvent) + func (s *Server) SetMaxCon(size uint32) + func (s *Server) SetProtoPack(proto IPack) + func (s *Server) SetWorkPoolSize(size uint32) + func (s *Server) Stop() + func (s *Server) Use(rf HandlerFunc) + func (s Server) GetConfig() *viper.Viper