Documentation
¶
Index ¶
- func NewChildPath(nodeID, actorID, childID interface{}) string
- func NewPath(nodeID, actorID interface{}) string
- type ActorPath
- type Component
- type IActor
- type IActorChild
- type IActorHandler
- type IActorSystem
- type IApplication
- type ICluster
- type IComponent
- type IComponentLifecycle
- type IConnector
- type IDiscovery
- type IEventData
- type IMember
- type INetParser
- type INode
- type IRespond
- type ISerializer
- type InvokeFunc
- type MemberListener
- type Message
- type OnConnectFunc
- type ProfileJSON
- type SID
- type UID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewChildPath ¶
func NewChildPath(nodeID, actorID, childID interface{}) string
Types ¶
type ActorPath ¶
ActorPath = NodeID . ActorID ActorPath = NodeID . ActorID . ChildID
func NewActorPath ¶
func ToActorPath ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component base component
func (*Component) App ¶
func (p *Component) App() IApplication
func (*Component) OnAfterInit ¶
func (*Component) OnAfterInit()
func (*Component) OnBeforeStop ¶
func (*Component) OnBeforeStop()
func (*Component) Set ¶
func (p *Component) Set(app IApplication)
type IActorChild ¶
type IActorHandler ¶
type IActorHandler interface {
AliasID() string // actorId
OnInit() // 当Actor启动前触发该函数
OnStop() // 当Actor停止前触发该函数
OnLocalReceived(m *Message) (bool, bool) // 当Actor接收local消息时触发该函数
OnRemoteReceived(m *Message) (bool, bool) // 当Actor接收remote消息时执行的函数
OnFindChild(m *Message) (IActor, bool) // 当actor查找子Actor时触发该函数
}
type IActorSystem ¶
type IActorSystem interface {
GetIActor(id string) (IActor, bool)
CreateActor(id string, handler IActorHandler) (IActor, error)
PostRemote(m *Message) bool
PostLocal(m *Message) bool
PostEvent(data IEventData)
Call(source, target, funcName string, arg interface{}) int32
CallWait(source, target, funcName string, arg interface{}, reply interface{}) int32
SetLocalInvoke(invoke InvokeFunc)
SetRemoteInvoke(invoke InvokeFunc)
SetCallTimeout(d time.Duration)
SetArrivalTimeout(t int64)
SetExecutionTimeout(t int64)
}
type IApplication ¶
type IApplication interface {
INode
Running() bool // 是否运行中
DieChan() chan bool // die chan
IsFrontend() bool // 是否为前端节点
Register(components ...IComponent) // 注册组件
Find(name string) IComponent // 根据name获取组件对象
Remove(name string) IComponent // 根据name移除组件对象
All() []IComponent // 获取所有组件列表
OnShutdown(fn ...func()) // 关闭前执行的函数
Startup() // 启动应用实例
Shutdown() // 关闭应用实例
Serializer() ISerializer // 序列化
Discovery() IDiscovery // 发现服务
Cluster() ICluster // 集群服务
ActorSystem() IActorSystem // actor系统
}
type ICluster ¶
type ICluster interface {
Init() // 初始化
PublishLocal(nodeId string, packet *cproto.ClusterPacket) error // 发布本地消息
PublishRemote(nodeId string, packet *cproto.ClusterPacket) error // 发布远程消息
RequestRemote(nodeId string, packet *cproto.ClusterPacket, timeout ...time.Duration) cproto.Response // 请求远程消息
Stop() // 停止
}
type IComponent ¶
type IComponent interface {
Name() string
App() IApplication
IComponentLifecycle
}
type IComponentLifecycle ¶
type IComponentLifecycle interface {
Set(app IApplication)
Init()
OnAfterInit()
OnBeforeStop()
OnStop()
}
type IConnector ¶
type IConnector interface {
IComponent
Start() // 启动连接器
Stop() // 停止连接器
OnConnect(fn OnConnectFunc) // 建立新连接时触发的函数
}
IConnector 网络连接器接口
type IDiscovery ¶
type IDiscovery interface {
Load(app IApplication)
Name() string // 发现服务名称
Map() map[string]IMember // 获取成员列表
ListByType(nodeType string, filterNodeId ...string) []IMember // 根据节点类型获取列表
Random(nodeType string) (IMember, bool) // 根据节点类型随机一个
GetType(nodeId string) (nodeType string, err error) // 根据节点id获取类型
GetMember(nodeId string) (member IMember, found bool) // 获取成员
AddMember(member IMember) // 添加成员
RemoveMember(nodeId string) // 移除成员
OnAddMember(listener MemberListener) // 添加成员监听函数
OnRemoveMember(listener MemberListener) // 移除成员监听函数
Stop()
}
IDiscovery 发现服务接口
type IEventData ¶
type INetParser ¶
type INetParser interface {
Load(application IApplication)
AddConnector(connector IConnector)
Connectors() []IConnector
}
INetParser 前端网络数据包解析器
type INode ¶
type INode interface {
NodeId() string // 节点id(全局唯一)
NodeType() string // 节点类型
Address() string // 对外网络监听地址(前端节点用)
RpcAddress() string // rpc监听地址(未用)
Settings() ProfileJSON // 节点配置参数
Enabled() bool // 是否启用
}
INode 节点信息
type ISerializer ¶
type ISerializer interface {
Marshal(interface{}) ([]byte, error) // 编码
Unmarshal([]byte, interface{}) error // 解码
Name() string // 序列化类型的名称
}
ISerializer 消息序列化
type InvokeFunc ¶
type InvokeFunc func(app IApplication, fi *creflect.FuncInfo, m *Message)
type MemberListener ¶
type MemberListener func(member IMember) // MemberListener 成员增、删监听函数
type Message ¶
type Message struct {
BuildTime int64 // message build time(ms)
PostTime int64 // post to actor time(ms)
Source string // 来源actor path
Target string // 目标actor path
FuncName string // 请求调用的函数名
Session *cproto.Session // session of gateway
Args interface{} // 请求的参数
Err error // 返回的错误
ClusterReply IRespond // 返回消息的接口
IsCluster bool // 是否为集群消息
ChanResult chan interface{} //
// contains filtered or unexported fields
}
func GetMessage ¶
func GetMessage() Message
func (*Message) TargetPath ¶
type ProfileJSON ¶
type ProfileJSON interface {
jsoniter.Any
GetConfig(path ...interface{}) ProfileJSON
GetString(path interface{}, defaultVal ...string) string
GetBool(path interface{}, defaultVal ...bool) bool
GetInt(path interface{}, defaultVal ...int) int
GetInt32(path interface{}, defaultVal ...int32) int32
GetInt64(path interface{}, defaultVal ...int64) int64
GetDuration(path interface{}, defaultVal ...time.Duration) time.Duration
Unmarshal(ptrVal interface{}) error
}
ProfileJSON profile配置文件读取接口
Click to show internal directories.
Click to hide internal directories.