Documentation ¶
Index ¶
- Constants
- func AssignActorId() int64
- func GetRpcMethodMap(rType reflect.Type, tagName string) map[string]string
- type ACTOR_TYPE
- type Actor
- func (a *Actor) Acotr() *Actor
- func (this *Actor) FindCall(funcName string) *CallFunc
- func (this *Actor) FindCallJson(funcName string) *CallFunc
- func (a *Actor) GetActorType() ACTOR_TYPE
- func (a *Actor) GetId() int64
- func (a *Actor) GetName() string
- func (a *Actor) GetRpcHead(ctx context.Context) rpc.RpcHead
- func (a *Actor) GetState() int32
- func (a *Actor) HasRpc(funcName string) bool
- func (a *Actor) Init()
- func (this *Actor) PacketFunc2(packet rpc.Packet) bool
- func (this *Actor) PacketFuncJson(packet rpc.Packet) bool
- func (this *Actor) RegisterCall(funcName string, call interface{})
- func (this *Actor) RegisterCallJson(funcName string, call interface{})
- func (a *Actor) RegisterTimer(duration time.Duration, fun func(), opts ...timer.OpOption)
- func (a *Actor) Send(head rpc.RpcHead, packet rpc.Packet)
- func (this *Actor) Send2(head rpc.RpcHead, buff []byte)
- func (this *Actor) SendJson(head api.JsonHead, buff []byte)
- func (a *Actor) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
- func (a *Actor) SetId(id int64)
- func (a *Actor) Start()
- func (a *Actor) Stop()
- func (a *Actor) Trace(funcName string)
- func (a *Actor) UpdateTimer(ctx context.Context, ptr uintptr)
- type ActorBase
- type ActorMgr
- func (a *ActorMgr) Init()
- func (a *ActorMgr) PacketFunc(packet rpc.Packet) bool
- func (a *ActorMgr) RegisterActor(ac IActor, params ...OpOption)
- func (a *ActorMgr) SendActor(funcName string, head rpc.RpcHead, packet rpc.Packet) bool
- func (a *ActorMgr) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
- func (a *ActorMgr) Start()
- type ActorPool
- type CallFunc
- type CallIO
- type CallIOJson
- type IActor
- type IActorMgr
- type IActorPool
- type ICluster
- type IVirtualActor
- type Op
- type OpOption
- type VirtualActor
- func (a *VirtualActor) AddActor(ac IActor)
- func (a *VirtualActor) DelActor(Id int64)
- func (a *VirtualActor) GeActorrNum() int
- func (a *VirtualActor) GetActor(Id int64) IActor
- func (a *VirtualActor) GetMgr() IActor
- func (a *VirtualActor) InitActor(pPool IActorPool, rType reflect.Type)
- func (a *VirtualActor) SendAcotr(head rpc.RpcHead, packet rpc.Packet) bool
Constants ¶
const ( ASF_NULL = iota ASF_RUN = iota ASF_STOP = iota //已经关闭 )
const (
DESDORY_EVENT = iota
)
Variables ¶
This section is empty.
Functions ¶
func AssignActorId ¶
func AssignActorId() int64
Types ¶
type ACTOR_TYPE ¶
type ACTOR_TYPE uint32
const ( ACTOR_TYPE_SINGLETON ACTOR_TYPE = iota //单列 ACTOR_TYPE_VIRTUAL ACTOR_TYPE = iota //玩家 必须初始一个全局的actor 作为类型判断 ACTOR_TYPE_POOL ACTOR_TYPE = iota //固定数量actor池 ACTOR_TYPE_STUB ACTOR_TYPE = iota //stub )
type Actor ¶
type Actor struct { ActorBase CallMap map[string]*CallFunc // contains filtered or unexported fields }
******************************************************** betree 核心actor模式 ********************************************************
func (*Actor) FindCallJson ¶ added in v1.6.3
func (*Actor) GetActorType ¶
func (a *Actor) GetActorType() ACTOR_TYPE
func (*Actor) PacketFuncJson ¶ added in v1.6.3
func (*Actor) RegisterCall ¶
func (*Actor) RegisterCallJson ¶ added in v1.6.3
func (*Actor) RegisterTimer ¶
type ActorBase ¶
type ActorBase struct { Self IActor //when parent interface class call interface, it call parent not child use for virtual // contains filtered or unexported fields }
******************************************************** betree 核心actor模式 ********************************************************
func (*ActorBase) IsActorType ¶
func (a *ActorBase) IsActorType(actorType ACTOR_TYPE) bool
type ActorMgr ¶
type ActorMgr struct {
// contains filtered or unexported fields
}
一些全局的actor,不可删除的,不用锁考虑性能 不是全局的actor,请使用actor pool
var (
MGR *ActorMgr
)
func (*ActorMgr) RegisterActor ¶
type ActorPool ¶
type ActorPool struct { MGR IActor // contains filtered or unexported fields }
******************************************************** actorpool 管理,不能动态分配 ********************************************************
func (*ActorPool) GetPoolSize ¶
type CallFunc ¶
type CallFunc struct { Func interface{} FuncType reflect.Type FuncVal reflect.Value FuncParams string }
******************************************************** betree 核心actor模式 ********************************************************
type CallIO ¶
******************************************************** betree 核心actor模式 ********************************************************
type CallIOJson ¶ added in v1.6.3
type CallIOJson struct { api.JsonHead *api.JsonPacket Buff []byte }
-------------json注册---------------------
type IActor ¶
type IActor interface { Init() Stop() Start() SendMsg(head rpc.RpcHead, funcName string, params ...interface{}) Send(head rpc.RpcHead, packet rpc.Packet) RegisterTimer(duration time.Duration, fun func(), opts ...timer.OpOption) //注册定时器,时间为纳秒 1000 * 1000 * 1000 GetId() int64 GetState() int32 GetRpcHead(ctx context.Context) rpc.RpcHead //rpc is safe GetName() string GetActorType() ACTOR_TYPE HasRpc(string) bool Acotr() *Actor // contains filtered or unexported methods }
******************************************************** betree 核心actor模式 ********************************************************
type IActorMgr ¶
type IActorMgr interface { Init() RegisterActor(ac IActor, params ...OpOption) //注册回调 PacketFunc(rpc.Packet) bool //回调函数 SendMsg(rpc.RpcHead, string, ...interface{}) }
一些全局的actor,不可删除的,不用锁考虑性能 不是全局的actor,请使用actor pool
type IActorPool ¶
type IActorPool interface {
SendAcotr(head rpc.RpcHead, packet rpc.Packet) bool //ACTOR_TYPE_VIRTUAL,ACTOR_TYPE_POOL特殊判断
}
******************************************************** betree 核心actor模式 ********************************************************
type ICluster ¶
type ICluster interface {
BindPacketFunc(packetFunc network.PacketFunc)
}
一些全局的actor,不可删除的,不用锁考虑性能 不是全局的actor,请使用actor pool
type IVirtualActor ¶
type IVirtualActor interface { GetActor(Id int64) IActor //获取actor AddActor(ac IActor) //添加actor DelActor(Id int64) //删除actor GetActorNum() int GetMgr() IActor }
******************************************************** actorpool 管理,这里的actor可以动态添加 ********************************************************
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
一些全局的actor,不可删除的,不用锁考虑性能 不是全局的actor,请使用actor pool
func (*Op) IsActorType ¶
func (op *Op) IsActorType(actorType ACTOR_TYPE) bool
type OpOption ¶
type OpOption func(*Op)
一些全局的actor,不可删除的,不用锁考虑性能 不是全局的actor,请使用actor pool
func WithType ¶
func WithType(actor_type ACTOR_TYPE) OpOption
type VirtualActor ¶
type VirtualActor struct { MGR IActor // contains filtered or unexported fields }
******************************************************** actorpool 管理,这里的actor可以动态添加 ********************************************************
func (*VirtualActor) AddActor ¶
func (a *VirtualActor) AddActor(ac IActor)
func (*VirtualActor) DelActor ¶
func (a *VirtualActor) DelActor(Id int64)
func (*VirtualActor) GeActorrNum ¶
func (a *VirtualActor) GeActorrNum() int
func (*VirtualActor) GetActor ¶
func (a *VirtualActor) GetActor(Id int64) IActor
func (*VirtualActor) GetMgr ¶
func (a *VirtualActor) GetMgr() IActor
func (*VirtualActor) InitActor ¶
func (a *VirtualActor) InitActor(pPool IActorPool, rType reflect.Type)