Documentation ¶
Index ¶
- Constants
- type BoxChannel
- func (bch *BoxChannel) Clean()
- func (bch *BoxChannel) Close()
- func (bch *BoxChannel) GetID() uint32
- func (bch *BoxChannel) GlobalIndex() protocol.GlobalIndexType
- func (bch *BoxChannel) Heartbeat() error
- func (bch *BoxChannel) IdentityID() string
- func (bch *BoxChannel) IdentityTag() string
- func (bch *BoxChannel) IsClose() bool
- func (bch *BoxChannel) LocalAddr() string
- func (bch *BoxChannel) Peek(length int) ([]byte, int, error)
- func (bch *BoxChannel) Read(pkg []byte, length int) (int, error)
- func (bch *BoxChannel) RemoteAddr() string
- func (bch *BoxChannel) Send(pkg []byte) error
- func (bch *BoxChannel) SetGlobalIndex(uuid protocol.GlobalIndexType)
- func (bch *BoxChannel) SetID(transID uint32)
- func (bch *BoxChannel) SetIdentityID(id string)
- func (bch *BoxChannel) SetIdentityTag(tag string)
- func (bch *BoxChannel) Size() uint32
- func (bch *BoxChannel) Write(pkg []byte, length int) (int, error)
- type BoxNetwork
- func (bn *BoxNetwork) ConnectTo(network, address string) (net.IBoxConn, error)
- func (bn *BoxNetwork) ConnectToService(service, network, address string)
- func (bn *BoxNetwork) Init()
- func (bn *BoxNetwork) ListenAt(network, address string) error
- func (bn *BoxNetwork) RegisterEventHandle(eventType net.EventType, handle NetActionCallback)
- func (bn *BoxNetwork) Start()
- func (bn *BoxNetwork) Stop()
- func (bn *BoxNetwork) Tick()
- func (bn *BoxNetwork) TryGetChannel(host string) *BoxChannel
- type ChannelCache
- type ComponentsManager
- type ConnectHandle
- type HostInfo
- type IComponent
- type IdentityChannelMap
- type LoggedHandler
- type NetActionCallback
- type NetworkOptions
- type Option
- type Options
- type ProxyCallBack
- type ProxyFinder
- type ProxyHandler
- type RawMsgHandler
- type RpcConfig
- type SBoxKey
- type ServiceBox
- func (sb *ServiceBox) AddComponent(component IComponent) error
- func (sb *ServiceBox) AddServicePackage(pack *idlrpc.PackageInfo) error
- func (sb *ServiceBox) GetConfig() config.Config
- func (sb *ServiceBox) GetDirectHande() transport.ITransport
- func (sb *ServiceBox) GetExtraProxy(uuid uint64, globalIndex protocol.GlobalIndexType, trans transport.ITransport) (idlrpc.IProxy, error)
- func (sb *ServiceBox) GetHttp() *http_proxy.HttpProxy
- func (sb *ServiceBox) GetLogger() slog.BoxLogger
- func (sb *ServiceBox) GetMessageHandle() *ServiceMessageHandle
- func (sb *ServiceBox) GetMongoClient() *mongodb.MongoDB
- func (sb *ServiceBox) GetOptions() string
- func (sb *ServiceBox) GetProxy(uuid uint64) (idlrpc.IProxy, error)
- func (sb *ServiceBox) GetProxyFromPeer(ctx idlrpc.IServiceContext, uuid uint64) (idlrpc.IProxy, error)
- func (sb *ServiceBox) GetProxyHandler() *ProxyHandler
- func (sb *ServiceBox) GetProxyWithNickName(uuid uint64, name string) (idlrpc.IProxy, error)
- func (sb *ServiceBox) GetRedisClient() redis.IClient
- func (sb *ServiceBox) GetScheduler() scheduler.ITimer
- func (sb *ServiceBox) GetTransport(uuid uint64) (*BoxChannel, error)
- func (sb *ServiceBox) Init(opts ...Option) error
- func (sb *ServiceBox) KickOutUser(proxy idlrpc.IProxy) error
- func (sb *ServiceBox) NewUuid() string
- func (sb *ServiceBox) ShutDown() error
- func (sb *ServiceBox) Start() error
- func (sb *ServiceBox) Tick()
- func (sb *ServiceBox) UnWatchService(name string, watcher ServiceWatcher) error
- func (sb *ServiceBox) UseTransHandler(handlerType int, handler TransHandlerFunc) error
- func (sb *ServiceBox) WatchService(uuid uint64, watcher ServiceWatcher) error
- func (sb *ServiceBox) WatchServiceWithNickName(uuid uint64, name string, watcher ServiceWatcher) error
- type ServiceBoxContext
- func (c *ServiceBoxContext) Clone() idlrpc.IServiceContext
- func (c *ServiceBoxContext) Debug(format string, i ...interface{})
- func (c *ServiceBoxContext) Error(format string, i ...interface{})
- func (c *ServiceBoxContext) GetIdentityID() string
- func (c *ServiceBoxContext) GetIdentityTag() string
- func (c *ServiceBoxContext) GetProxy(uuid uint64) idlrpc.IProxy
- func (c *ServiceBoxContext) GetProxyFromPeer(uuid uint64) idlrpc.IProxy
- func (c *ServiceBoxContext) GetProxyWithNickname(uuid uint64, name string) idlrpc.IProxy
- func (c *ServiceBoxContext) GetServiceBox() *ServiceBox
- func (c *ServiceBoxContext) GetTransport() transport.ITransport
- func (c *ServiceBoxContext) Info(format string, i ...interface{})
- func (c *ServiceBoxContext) Warning(format string, i ...interface{})
- type ServiceCfg
- type ServiceEvent
- type ServiceMessageHandle
- func (mh *ServiceMessageHandle) GetTransport(identityID string) transport.ITransport
- func (mh *ServiceMessageHandle) Init()
- func (mh *ServiceMessageHandle) OnIdentityNotify(trans transport.ITransport, identityID string, identityTag string)
- func (mh *ServiceMessageHandle) OnLoggedOut(index protocol.GlobalIndexType)
- func (mh *ServiceMessageHandle) OnRawMessage(trans transport.ITransport, msg []byte)
- func (mh *ServiceMessageHandle) SetLoggedOutHandle(cb LoggedHandler)
- func (mh *ServiceMessageHandle) SetRawMsgHandle(handler RawMsgHandler)
- func (mh *ServiceMessageHandle) UnInit()
- type ServiceWatcher
- type TransHandlerFunc
- type WatcherList
- type WatcherManager
Constants ¶
const ( TransHandlerOnConnect = iota // 新连接连接上box时触发 TransHandlerOnMessage TransHandlerBeforeCall TransHandlerOnClose TransHandlerMax )
const ( ServiceAdd = iota ServiceClose )
const (
ReceiveBufferLen = 1024 * 16
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoxChannel ¶
type BoxChannel struct {
// contains filtered or unexported fields
}
BoxChannel implement rpc backend go transport interface one connect has its own channel
func NewBoxChannel ¶
func NewBoxChannel(conn net.IBoxConn, cacheLen int) *BoxChannel
func (*BoxChannel) GetID ¶
func (bch *BoxChannel) GetID() uint32
func (*BoxChannel) GlobalIndex ¶
func (bch *BoxChannel) GlobalIndex() protocol.GlobalIndexType
func (*BoxChannel) Heartbeat ¶ added in v0.4.24
func (bch *BoxChannel) Heartbeat() error
func (*BoxChannel) IdentityID ¶ added in v0.5.3
func (bch *BoxChannel) IdentityID() string
func (*BoxChannel) IdentityTag ¶ added in v0.5.3
func (bch *BoxChannel) IdentityTag() string
func (*BoxChannel) IsClose ¶
func (bch *BoxChannel) IsClose() bool
func (*BoxChannel) LocalAddr ¶
func (bch *BoxChannel) LocalAddr() string
func (*BoxChannel) Peek ¶
func (bch *BoxChannel) Peek(length int) ([]byte, int, error)
Peek read buffer without modify read point
func (*BoxChannel) RemoteAddr ¶
func (bch *BoxChannel) RemoteAddr() string
func (*BoxChannel) Send ¶
func (bch *BoxChannel) Send(pkg []byte) error
func (*BoxChannel) SetGlobalIndex ¶
func (bch *BoxChannel) SetGlobalIndex(uuid protocol.GlobalIndexType)
func (*BoxChannel) SetID ¶
func (bch *BoxChannel) SetID(transID uint32)
func (*BoxChannel) SetIdentityID ¶ added in v0.5.3
func (bch *BoxChannel) SetIdentityID(id string)
func (*BoxChannel) SetIdentityTag ¶ added in v0.5.3
func (bch *BoxChannel) SetIdentityTag(tag string)
func (*BoxChannel) Size ¶
func (bch *BoxChannel) Size() uint32
type BoxNetwork ¶
type BoxNetwork struct {
// contains filtered or unexported fields
}
BoxNetwork service box network manager
func NewBoxNetWork ¶
func NewBoxNetWork(option *NetworkOptions) *BoxNetwork
func (*BoxNetwork) ConnectTo ¶
func (bn *BoxNetwork) ConnectTo(network, address string) (net.IBoxConn, error)
ConnectTo connect to other server block
func (*BoxNetwork) ConnectToService ¶
func (bn *BoxNetwork) ConnectToService(service, network, address string)
func (*BoxNetwork) ListenAt ¶
func (bn *BoxNetwork) ListenAt(network, address string) error
ListenAt start Server at address !
func (*BoxNetwork) RegisterEventHandle ¶
func (bn *BoxNetwork) RegisterEventHandle(eventType net.EventType, handle NetActionCallback)
func (*BoxNetwork) Start ¶
func (bn *BoxNetwork) Start()
Start start all box network loop, like redis, zookeeper
func (*BoxNetwork) TryGetChannel ¶ added in v0.4.7
func (bn *BoxNetwork) TryGetChannel(host string) *BoxChannel
type ChannelCache ¶
type ChannelCache map[string]*BoxChannel
ChannelCache LoopCache map[string]*boxNetLoop
type ComponentsManager ¶ added in v0.4.31
type ComponentsManager struct {
// contains filtered or unexported fields
}
ComponentsManager 组件管理工具
func (*ComponentsManager) GetComponent ¶ added in v0.4.31
func (c *ComponentsManager) GetComponent(name string) IComponent
func (*ComponentsManager) RegisterComponent ¶ added in v0.4.31
func (c *ComponentsManager) RegisterComponent(component IComponent) error
RegisterComponent 注册组件到box, 一个名字只允许注册一次
func (*ComponentsManager) UnRegisterComponent ¶ added in v0.4.31
func (c *ComponentsManager) UnRegisterComponent(name string) error
UnRegisterComponent 移除某个组件,非协程安全
type ConnectHandle ¶ added in v0.4.4
type IComponent ¶ added in v0.4.31
type IComponent interface { // GetName 返回自定义组件名,用于管理器管理,由外部用户自定义 GetName() string // OnInit 初始化函数,在系统组件初始化完成之后由box进行调用,这个时候系统组件处于非运行状态,但是内存和资源已经申请完毕 OnInit(*ServiceBox) error // OnStart 启动函数,在box的其余组件成功启动后,由系统调用 OnStart(*ServiceBox) error // OnStop 停机通知函数,在box其余组件停机前调用,这个时候系统其余组件尚未销毁其资源 OnStop(*ServiceBox) error // OnDestroy 销毁函数,销毁组件申请的资源,如果是使用的box系统的资源,应该在这个时候销毁 OnDestroy(*ServiceBox) error // OnTick 主循环函数,在主线程中执行,请不要调用阻塞函数 OnTick() }
type IdentityChannelMap ¶ added in v0.5.3
type IdentityChannelMap map[string]transport.ITransport
IdentityChannelMap channel cache
type LoggedHandler ¶ added in v0.5.3
type LoggedHandler func(index protocol.GlobalIndexType)
LoggedHandler User logout notification handle
type NetActionCallback ¶
type NetActionCallback func(string, *BoxChannel, error)
NetActionCallback network event call back
type NetworkOptions ¶ added in v0.4.26
type NetworkOptions struct {
RecvBufferLen int `yaml:"recv_buffer_len"` // Message receiving buffer length.
}
BoxNetwork service box network manager
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func NewBoxOptions ¶ added in v0.4.13
func NewBoxOptions() *Options
func (*Options) GetOneHostIp ¶
type ProxyCallBack ¶
type ProxyCallBack func(string, *BoxChannel, error) //get proxy call back
type ProxyFinder ¶ added in v0.4.4
ProxyFinder 服务proxy获取接口
type ProxyHandler ¶
type ProxyHandler struct {
// contains filtered or unexported fields
}
func (*ProxyHandler) NewReplaceID ¶
func (p *ProxyHandler) NewReplaceID() uint32
func (*ProxyHandler) OnRelay ¶
func (p *ProxyHandler) OnRelay(from transport.ITransport, header *protocol.RpcMsgHeader) error
func (*ProxyHandler) UseHandler ¶ added in v0.5.7
func (p *ProxyHandler) UseHandler(handlerType int, handler TransHandlerFunc) error
UseHandler 设置扩展函数
type RawMsgHandler ¶ added in v0.5.7
type RawMsgHandler func(trans transport.ITransport, msg []byte) error
RawMsgHandler raw message handle
type ServiceBox ¶
type ServiceBox struct {
// contains filtered or unexported fields
}
func MakeServiceBox ¶
func MakeServiceBox() *ServiceBox
func (*ServiceBox) AddComponent ¶ added in v0.4.31
func (sb *ServiceBox) AddComponent(component IComponent) error
func (*ServiceBox) AddServicePackage ¶
func (sb *ServiceBox) AddServicePackage(pack *idlrpc.PackageInfo) error
func (*ServiceBox) GetConfig ¶
func (sb *ServiceBox) GetConfig() config.Config
func (*ServiceBox) GetDirectHande ¶ added in v0.5.7
func (sb *ServiceBox) GetDirectHande() transport.ITransport
GetDirectHande 返回直连模式下的handler
func (*ServiceBox) GetExtraProxy ¶ added in v0.5.3
func (sb *ServiceBox) GetExtraProxy(uuid uint64, globalIndex protocol.GlobalIndexType, trans transport.ITransport) (idlrpc.IProxy, error)
func (*ServiceBox) GetHttp ¶ added in v0.4.19
func (sb *ServiceBox) GetHttp() *http_proxy.HttpProxy
GetHttp 返回http模块,需要配置中开启http模块,并且以网关模式启动plato应用
func (*ServiceBox) GetLogger ¶
func (sb *ServiceBox) GetLogger() slog.BoxLogger
func (*ServiceBox) GetMessageHandle ¶ added in v0.5.3
func (sb *ServiceBox) GetMessageHandle() *ServiceMessageHandle
func (*ServiceBox) GetMongoClient ¶ added in v0.4.2
func (sb *ServiceBox) GetMongoClient() *mongodb.MongoDB
func (*ServiceBox) GetOptions ¶
func (sb *ServiceBox) GetOptions() string
func (*ServiceBox) GetProxyFromPeer ¶
func (sb *ServiceBox) GetProxyFromPeer(ctx idlrpc.IServiceContext, uuid uint64) (idlrpc.IProxy, error)
func (*ServiceBox) GetProxyHandler ¶ added in v0.5.7
func (sb *ServiceBox) GetProxyHandler() *ProxyHandler
GetProxyHandler 返回proxy模块,需要配置中开启proxy模块,并且以网关模式启动plato应用
func (*ServiceBox) GetProxyWithNickName ¶
func (*ServiceBox) GetRedisClient ¶ added in v0.4.2
func (sb *ServiceBox) GetRedisClient() redis.IClient
func (*ServiceBox) GetScheduler ¶ added in v0.4.24
func (sb *ServiceBox) GetScheduler() scheduler.ITimer
func (*ServiceBox) GetTransport ¶
func (sb *ServiceBox) GetTransport(uuid uint64) (*BoxChannel, error)
func (*ServiceBox) Init ¶
func (sb *ServiceBox) Init(opts ...Option) error
func (*ServiceBox) KickOutUser ¶ added in v0.4.24
func (sb *ServiceBox) KickOutUser(proxy idlrpc.IProxy) error
KickOutUser 踢用户下线
func (*ServiceBox) NewUuid ¶ added in v0.5.1
func (sb *ServiceBox) NewUuid() string
func (*ServiceBox) ShutDown ¶
func (sb *ServiceBox) ShutDown() error
func (*ServiceBox) Start ¶
func (sb *ServiceBox) Start() error
func (*ServiceBox) Tick ¶
func (sb *ServiceBox) Tick()
func (*ServiceBox) UnWatchService ¶ added in v0.4.4
func (sb *ServiceBox) UnWatchService(name string, watcher ServiceWatcher) error
func (*ServiceBox) UseTransHandler ¶ added in v0.5.7
func (sb *ServiceBox) UseTransHandler(handlerType int, handler TransHandlerFunc) error
func (*ServiceBox) WatchService ¶ added in v0.4.4
func (sb *ServiceBox) WatchService(uuid uint64, watcher ServiceWatcher) error
func (*ServiceBox) WatchServiceWithNickName ¶ added in v0.4.4
func (sb *ServiceBox) WatchServiceWithNickName(uuid uint64, name string, watcher ServiceWatcher) error
type ServiceBoxContext ¶ added in v0.5.4
type ServiceBoxContext struct { *idlrpc.RpcContext // contains filtered or unexported fields }
ServiceBoxContext service-box context
func NewServiceBoxContext ¶ added in v0.5.4
func NewServiceBoxContext(box *ServiceBox) *ServiceBoxContext
func (*ServiceBoxContext) Clone ¶ added in v0.5.6
func (c *ServiceBoxContext) Clone() idlrpc.IServiceContext
Clone clone 一个新的上下文,保留连接,身份信息但是不保留global index 和 用户协议的中间态
func (*ServiceBoxContext) Debug ¶ added in v0.5.8
func (c *ServiceBoxContext) Debug(format string, i ...interface{})
func (*ServiceBoxContext) Error ¶ added in v0.5.4
func (c *ServiceBoxContext) Error(format string, i ...interface{})
func (*ServiceBoxContext) GetIdentityID ¶ added in v0.5.4
func (c *ServiceBoxContext) GetIdentityID() string
func (*ServiceBoxContext) GetIdentityTag ¶ added in v0.5.4
func (c *ServiceBoxContext) GetIdentityTag() string
func (*ServiceBoxContext) GetProxy ¶ added in v0.5.4
func (c *ServiceBoxContext) GetProxy(uuid uint64) idlrpc.IProxy
func (*ServiceBoxContext) GetProxyFromPeer ¶ added in v0.5.4
func (c *ServiceBoxContext) GetProxyFromPeer(uuid uint64) idlrpc.IProxy
func (*ServiceBoxContext) GetProxyWithNickname ¶ added in v0.5.4
func (c *ServiceBoxContext) GetProxyWithNickname(uuid uint64, name string) idlrpc.IProxy
func (*ServiceBoxContext) GetServiceBox ¶ added in v0.5.4
func (c *ServiceBoxContext) GetServiceBox() *ServiceBox
func (*ServiceBoxContext) GetTransport ¶ added in v0.5.4
func (c *ServiceBoxContext) GetTransport() transport.ITransport
func (*ServiceBoxContext) Info ¶ added in v0.5.4
func (c *ServiceBoxContext) Info(format string, i ...interface{})
func (*ServiceBoxContext) Warning ¶ added in v0.5.4
func (c *ServiceBoxContext) Warning(format string, i ...interface{})
type ServiceCfg ¶
type ServiceEvent ¶ added in v0.4.4
type ServiceEvent int
ServiceEvent 服务变化事件类型 ServiceAdd 添加 ServiceClose 关闭
type ServiceMessageHandle ¶ added in v0.5.3
type ServiceMessageHandle struct {
// contains filtered or unexported fields
}
ServiceMessageHandle The RPC message handling handle
func (*ServiceMessageHandle) GetTransport ¶ added in v0.5.3
func (mh *ServiceMessageHandle) GetTransport(identityID string) transport.ITransport
GetTransport getting the transport by identity id
func (*ServiceMessageHandle) Init ¶ added in v0.5.3
func (mh *ServiceMessageHandle) Init()
func (*ServiceMessageHandle) OnIdentityNotify ¶ added in v0.5.3
func (mh *ServiceMessageHandle) OnIdentityNotify(trans transport.ITransport, identityID string, identityTag string)
OnIdentityNotify This function is triggered when the other connection notifies it of its identity
func (*ServiceMessageHandle) OnLoggedOut ¶ added in v0.5.3
func (mh *ServiceMessageHandle) OnLoggedOut(index protocol.GlobalIndexType)
OnLoggedOut This function is triggered when the external connection is broken.
func (*ServiceMessageHandle) OnRawMessage ¶ added in v0.5.7
func (mh *ServiceMessageHandle) OnRawMessage(trans transport.ITransport, msg []byte)
OnRawMessage This function is triggered when the other connection sends a message
func (*ServiceMessageHandle) SetLoggedOutHandle ¶ added in v0.5.3
func (mh *ServiceMessageHandle) SetLoggedOutHandle(cb LoggedHandler)
SetLoggedOutHandle Call in the main coroutine and set the user logout response handle to ensure coroutine security.
func (*ServiceMessageHandle) SetRawMsgHandle ¶ added in v0.5.7
func (mh *ServiceMessageHandle) SetRawMsgHandle(handler RawMsgHandler)
SetRawMsgHandle Call in the main coroutine and set the raw message handle to ensure coroutine security.
func (*ServiceMessageHandle) UnInit ¶ added in v0.5.3
func (mh *ServiceMessageHandle) UnInit()
type ServiceWatcher ¶ added in v0.4.4
type ServiceWatcher func(eType ServiceEvent, name string, host string, proxy idlrpc.IProxy)
ServiceWatcher 是服务监听回调函数类型
type TransHandlerFunc ¶ added in v0.5.7
type TransHandlerFunc func(trans transport.ITransport) error
TransHandlerFunc trans handler 用于扩展处理box's 连接
type WatcherList ¶ added in v0.4.4
type WatcherList struct {
// contains filtered or unexported fields
}
type WatcherManager ¶ added in v0.4.4
type WatcherManager struct {
// contains filtered or unexported fields
}
WatcherManager 服务变化监听管理
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package common some common define
|
Package common some common define |
example
|
|
testcallee
Generated by the go idl tools.
|
Generated by the go idl tools. |
testcaller
Generated by the go idl tools.
|
Generated by the go idl tools. |
internal
|
|
util
|
|
config/loader/memory
Package memory loader will load config info from source, encoder it and store to memory
|
Package memory loader will load config info from source, encoder it and store to memory |