Documentation ¶
Index ¶
- Constants
- Variables
- type AsyncHandler
- type BaseService
- func (b *BaseService) Alias() string
- func (b *BaseService) AsyncHandler(ctx *protocol.Context, tag struct{})
- func (b *BaseService) AsyncHandler0(ctx *protocol.Context, req *struct{}, rsp *struct{}, tag struct{}) *CallMode
- func (b *BaseService) Handler(ctx *protocol.Context)
- func (b *BaseService) Handler0(ctx *protocol.Context, req *struct{}, rsp *struct{}) *CallMode
- func (b *BaseService) Init(v ...interface{}) IService
- func (b *BaseService) PreHandler0() (f func(ctx *protocol.Context), sort int)
- func (b *BaseService) PreHandler1() (f func(ctx *protocol.Context), sort int)
- func (b *BaseService) PreHandler2() (f func(ctx *protocol.Context), sort int)
- func (b *BaseService) PreHandler3() (f func(ctx *protocol.Context), sort int)
- type BuiltinService
- func (b *BuiltinService) Alias() string
- func (b *BuiltinService) Benchmark(ctx *protocol.Context, args *protocol.BenchmarkMessage, ...) *CallMode
- func (b *BuiltinService) Heartbeat(ctx *protocol.Context, args *string, reply *string, tag struct{}) *CallMode
- func (b *BuiltinService) Init(v ...interface{}) IService
- type CallMode
- type CallType
- type Client
- func (c *Client) AddPlugin(ps ...Plugin)
- func (c *Client) Call(servicePath string, serviceMethod string, metadata map[string]string, ...) error
- func (c *Client) Close()
- func (c *Client) CtxChan() <-chan *protocol.Context
- func (c *Client) MainGoroutine()
- func (c *Client) OnBoot(e gnet.Engine) (action gnet.Action)
- func (c *Client) OnClose(conn gnet.Conn, err error) gnet.Action
- func (c *Client) OnOpen(conn gnet.Conn) ([]byte, gnet.Action)
- func (c *Client) OnShutdown(e gnet.Engine)
- func (c *Client) OnTick() (delay time.Duration, action gnet.Action)
- func (c *Client) OnTraffic(conn gnet.Conn) (action gnet.Action)
- func (c *Client) Register(is ...IService) *Client
- func (c *Client) Run() (*Client, error)
- type ConnMatrix
- func (c *ConnMatrix) Add(conn gnet.Conn)
- func (c *ConnMatrix) Broadcast(buffer *bytebufferpool.ByteBuffer)
- func (c *ConnMatrix) BroadcastExceptOne(buffer *bytebufferpool.ByteBuffer, id string)
- func (c *ConnMatrix) BroadcastSomeone(buffer *bytebufferpool.ByteBuffer, ids []string)
- func (c *ConnMatrix) Len() int
- func (c *ConnMatrix) Remove(id string)
- func (c *ConnMatrix) SendToConn(buffer *bytebufferpool.ByteBuffer, conn gnet.Conn)
- func (c *ConnMatrix) SendToOne(buffer *bytebufferpool.ByteBuffer, id string)
- func (c *ConnMatrix) SetAsync(async bool)
- type Handler
- type HandlerSet
- type IService
- type OptionFn
- func WithAntExpiryDuration(expiryDuration time.Duration) OptionFn
- func WithClientSyncMode() OptionFn
- func WithDefaultService() OptionFn
- func WithDisablePurge(disable bool) OptionFn
- func WithLoadBalancing(lb int) OptionFn
- func WithLockOSThread(lockOSThread bool) OptionFn
- func WithLogLevel(lvl logging.Level) OptionFn
- func WithLogPath(fileName string) OptionFn
- func WithLogger(logger logging.Logger) OptionFn
- func WithMainGoroutineChannelCap(cap int) OptionFn
- func WithMaxBlockingTasks(maxBlockingTasks int) OptionFn
- func WithMulticastInterfaceIndex(idx int) OptionFn
- func WithMulticore(multicore bool) OptionFn
- func WithNonblocking(nonblocking bool) OptionFn
- func WithNumEventLoop(numEventLoop int) OptionFn
- func WithPanicHandler(panicHandler func(interface{})) OptionFn
- func WithPreAlloc(preAlloc bool) OptionFn
- func WithPrintRegisteredMethod() OptionFn
- func WithReadBufferCap(readBufferCap int) OptionFn
- func WithReuseAddr(reuseAddr bool) OptionFn
- func WithReusePort(reusePort bool) OptionFn
- func WithSocketRecvBuffer(recvBuf int) OptionFn
- func WithSocketSendBuffer(sendBuf int) OptionFn
- func WithTCPKeepAlive(tcpKeepAlive time.Duration) OptionFn
- func WithTCPNoDelay(tcpNoDelay int) OptionFn
- func WithTicker(ticker bool) OptionFn
- func WithWriteBufferCap(writeBufferCap int) OptionFn
- type Plugin
- type PluginType
- type PreFunc
- type PreFuncList
- type PreHandler
- type Reset
- type Server
- func (s *Server) AddPlugin(ps ...Plugin)
- func (s *Server) OnBoot(engine gnet.Engine) (action gnet.Action)
- func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action)
- func (s *Server) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
- func (s *Server) OnShutdown(engine gnet.Engine)
- func (s *Server) OnTick() (delay time.Duration, action gnet.Action)
- func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action)
- func (s *Server) Register(is ...IService)
- func (s *Server) Run(netWork string, addr string) error
- func (s *Server) SendMessage(conn gnet.Conn, path, method string, metadata map[string]string, body []byte)
- func (s *Server) UseAuthFunc(f func(ctx *protocol.Context, token string) error)
- type Service
- type ServiceSet
- func (s *ServiceSet) AsyncCall(ctx *protocol.Context) error
- func (s *ServiceSet) Call(ctx *protocol.Context, tmpService *Service, mType *methodType, isAsync bool) error
- func (s *ServiceSet) GetService(sp string) (bool, *Service)
- func (s *ServiceSet) Register(v IService, isPrint bool)
- func (s *ServiceSet) SyncCall(ctx *protocol.Context) error
Constants ¶
View Source
const ( TcpNetwork = "tcp" Tcp6Network = "tcp6" UdpNetwork = "udp" Udp6Network = "udp6" UnixNetwork = "unix" )
View Source
const (
BuiltinServiceName = "Builtin"
)
Variables ¶
View Source
var ( NotFoundMethod = errors.New("not found method") NotFoundService = errors.New("not found service") )
Functions ¶
This section is empty.
Types ¶
type AsyncHandler ¶
type BaseService ¶
type BaseService struct { }
func (*BaseService) Alias ¶
func (b *BaseService) Alias() string
func (*BaseService) AsyncHandler ¶
func (b *BaseService) AsyncHandler(ctx *protocol.Context, tag struct{})
AsyncHandler Async handler
func (*BaseService) AsyncHandler0 ¶
func (b *BaseService) AsyncHandler0(ctx *protocol.Context, req *struct{}, rsp *struct{}, tag struct{}) *CallMode
AsyncHandler0 Async handler
func (*BaseService) Handler ¶
func (b *BaseService) Handler(ctx *protocol.Context)
Handler sync handler
func (*BaseService) Handler0 ¶
func (b *BaseService) Handler0(ctx *protocol.Context, req *struct{}, rsp *struct{}) *CallMode
Handler0 sync handler
func (*BaseService) Init ¶
func (b *BaseService) Init(v ...interface{}) IService
func (*BaseService) PreHandler0 ¶
func (b *BaseService) PreHandler0() (f func(ctx *protocol.Context), sort int)
PreHandler0 pre execute a smaller sort value is executed first
func (*BaseService) PreHandler1 ¶
func (b *BaseService) PreHandler1() (f func(ctx *protocol.Context), sort int)
PreHandler1 pre execute
func (*BaseService) PreHandler2 ¶
func (b *BaseService) PreHandler2() (f func(ctx *protocol.Context), sort int)
PreHandler2 pre execute
func (*BaseService) PreHandler3 ¶
func (b *BaseService) PreHandler3() (f func(ctx *protocol.Context), sort int)
PreHandler3 pre execute
type BuiltinService ¶
type BuiltinService struct {
// contains filtered or unexported fields
}
func (*BuiltinService) Alias ¶
func (b *BuiltinService) Alias() string
func (*BuiltinService) Benchmark ¶
func (b *BuiltinService) Benchmark(ctx *protocol.Context, args *protocol.BenchmarkMessage, reply *protocol.BenchmarkMessage, tag struct{}) *CallMode
func (*BuiltinService) Init ¶
func (b *BuiltinService) Init(v ...interface{}) IService
type CallMode ¶
func CallBroadcast ¶
func CallBroadcast() *CallMode
func CallBroadcastExceptSelf ¶
func CallBroadcastExceptSelf() *CallMode
type Client ¶
type Client struct { *gnet.BuiltinEventEngine // contains filtered or unexported fields }
func (*Client) MainGoroutine ¶
func (c *Client) MainGoroutine()
func (*Client) OnShutdown ¶
func (c *Client) OnShutdown(e gnet.Engine)
type ConnMatrix ¶
type ConnMatrix struct {
// contains filtered or unexported fields
}
func (*ConnMatrix) Add ¶
func (c *ConnMatrix) Add(conn gnet.Conn)
func (*ConnMatrix) Broadcast ¶
func (c *ConnMatrix) Broadcast(buffer *bytebufferpool.ByteBuffer)
func (c *ConnMatrix) RemoveAll(msg string) { if c.sync { c.locker.Lock() defer c.locker.Unlock() } if c.async{ c.asyncMap. } for k, v := range c.connMap { v.Close(msg) delete(c.connMap, k) } }
func (*ConnMatrix) BroadcastExceptOne ¶
func (c *ConnMatrix) BroadcastExceptOne(buffer *bytebufferpool.ByteBuffer, id string)
func (*ConnMatrix) BroadcastSomeone ¶
func (c *ConnMatrix) BroadcastSomeone(buffer *bytebufferpool.ByteBuffer, ids []string)
func (*ConnMatrix) Len ¶
func (c *ConnMatrix) Len() int
func (*ConnMatrix) Remove ¶
func (c *ConnMatrix) Remove(id string)
func (*ConnMatrix) SendToConn ¶
func (c *ConnMatrix) SendToConn(buffer *bytebufferpool.ByteBuffer, conn gnet.Conn)
func (*ConnMatrix) SendToOne ¶
func (c *ConnMatrix) SendToOne(buffer *bytebufferpool.ByteBuffer, id string)
func (*ConnMatrix) SetAsync ¶
func (c *ConnMatrix) SetAsync(async bool)
type HandlerSet ¶
type HandlerSet struct {
// contains filtered or unexported fields
}
func NewHandlerSet ¶
func NewHandlerSet() *HandlerSet
func (*HandlerSet) Register ¶
func (h *HandlerSet) Register(v IService, isPrint bool) *HandlerSet
type OptionFn ¶
type OptionFn func(*serverOption)
func WithAntExpiryDuration ¶
func WithClientSyncMode ¶
func WithClientSyncMode() OptionFn
func WithDefaultService ¶
func WithDefaultService() OptionFn
func WithDisablePurge ¶
func WithLoadBalancing ¶
func WithLockOSThread ¶
func WithLogLevel ¶
func WithLogPath ¶
func WithLogger ¶
func WithMaxBlockingTasks ¶
func WithMulticore ¶
func WithNonblocking ¶
func WithNumEventLoop ¶
func WithPanicHandler ¶
func WithPanicHandler(panicHandler func(interface{})) OptionFn
func WithPreAlloc ¶
func WithPrintRegisteredMethod ¶
func WithPrintRegisteredMethod() OptionFn
func WithReadBufferCap ¶
func WithReuseAddr ¶
func WithReusePort ¶
func WithSocketRecvBuffer ¶
func WithSocketSendBuffer ¶
func WithTCPKeepAlive ¶
func WithTCPNoDelay ¶
func WithTicker ¶
func WithWriteBufferCap ¶
type Plugin ¶
type Plugin interface { OnDo(v ...interface{}) error Type() PluginType Init(v ...interface{}) Plugin }
type PluginType ¶
type PluginType uint16
const ( PluginTypeOnBoot PluginType = iota PluginTypeOnShutdown PluginTypeOnOpen PluginTypeOnClose PluginTypeOnTraffic PluginTypeOnTick )
type PreFuncList ¶
type PreFuncList []PreFunc
func (PreFuncList) Call ¶
func (p PreFuncList) Call(ctx *protocol.Context)
func (PreFuncList) Len ¶
func (p PreFuncList) Len() int
func (PreFuncList) Less ¶
func (p PreFuncList) Less(i, j int) bool
func (PreFuncList) Swap ¶
func (p PreFuncList) Swap(i, j int)
type PreHandler ¶
type Server ¶
type Server struct { gnet.BuiltinEventEngine // contains filtered or unexported fields }
func (*Server) OnShutdown ¶
func (s *Server) OnShutdown(engine gnet.Engine)
func (*Server) SendMessage ¶
type ServiceSet ¶
type ServiceSet struct {
// contains filtered or unexported fields
}
func NewServiceSet ¶
func NewServiceSet(pool *ants.Pool, connMatrix *ConnMatrix) *ServiceSet
func (*ServiceSet) GetService ¶
func (s *ServiceSet) GetService(sp string) (bool, *Service)
func (*ServiceSet) Register ¶
func (s *ServiceSet) Register(v IService, isPrint bool)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.