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 ¶ added in v1.3.1
func NewChildPath(nodeID, actorID, childID interface{}) string
Types ¶
type ActorPath ¶ added in v1.3.0
ActorPath = NodeID . ActorID ActorPath = NodeID . ActorID . ChildID
func NewActorPath ¶ added in v1.3.0
func ToActorPath ¶ added in v1.3.0
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component base component
func (*Component) App ¶ added in v1.3.0
func (p *Component) App() IApplication
func (*Component) OnAfterInit ¶
func (*Component) OnAfterInit()
func (*Component) OnBeforeStop ¶
func (*Component) OnBeforeStop()
func (*Component) Set ¶ added in v1.3.0
func (p *Component) Set(app IApplication)
type IActorChild ¶ added in v1.3.0
type IActorHandler ¶ added in v1.3.0
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时触发该函数 Exit() // 执行Actor退出 }
type IActorSystem ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
type IComponentLifecycle interface { Set(app IApplication) Init() OnAfterInit() OnBeforeStop() OnStop() }
type IConnector ¶
type IConnector interface { IComponent Start() // 启动连接器 Stop() // 停止连接器 OnConnect(fn OnConnectFunc) // 建立新连接时触发的函数 }
IConnector 网络连接器接口
type IDiscovery ¶ added in v1.1.5
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 ¶ added in v1.3.0
type INetParser ¶ added in v1.3.0
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 ¶ added in v1.3.0
type InvokeFunc func(app IApplication, fi *creflect.FuncInfo, m *Message)
type MemberListener ¶ added in v1.1.5
type MemberListener func(member IMember) // MemberListener 成员增、删监听函数
type Message ¶ added in v1.3.0
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 ¶ added in v1.3.0
func GetMessage() *Message
func (*Message) TargetPath ¶ added in v1.3.0
type OnConnectFunc ¶ added in v1.3.0
OnConnectFunc 建立连接时监听的函数
type ProfileJSON ¶ added in v1.3.0
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 Marshal(ptrVal interface{}) error }
ProfileJSON profile配置文件读取接口
Click to show internal directories.
Click to hide internal directories.