cherryActor

package
v1.3.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 16 Imported by: 6

Documentation

Index

Constants

View Source
const (
	LocalName  = "local"
	RemoteName = "remote"
)

Variables

View Source
var (
	ErrForbiddenToCallSelf       = cerror.Errorf("SendActorID cannot be equal to TargetActorID")
	ErrForbiddenCreateChildActor = cerror.Errorf("Forbidden create child actor")
	ErrActorIDIsNil              = cerror.Error("actorID is nil.")
)
View Source
var (
	Name = "actor_component"
)

Functions

func EncodeArgs added in v1.3.1

func EncodeArgs(app cfacade.IApplication, fi *creflect.FuncInfo, index int, m *cfacade.Message) error

func EncodeLocalArgs added in v1.3.1

func EncodeLocalArgs(app cfacade.IApplication, fi *creflect.FuncInfo, m *cfacade.Message) error

func EncodeRemoteArgs added in v1.3.1

func EncodeRemoteArgs(app cfacade.IApplication, fi *creflect.FuncInfo, m *cfacade.Message) error

func InvokeLocalFunc added in v1.3.1

func InvokeLocalFunc(app cfacade.IApplication, fi *creflect.FuncInfo, m *cfacade.Message)

func InvokeRemoteFunc added in v1.3.1

func InvokeRemoteFunc(app cfacade.IApplication, fi *creflect.FuncInfo, m *cfacade.Message)

Types

type Actor

type Actor struct {
	// contains filtered or unexported fields
}

func (*Actor) ActorID

func (p *Actor) ActorID() string

func (*Actor) App

func (p *Actor) App() cfacade.IApplication

func (*Actor) Call

func (p *Actor) Call(targetPath, funcName string, arg interface{}) int32

func (*Actor) CallWait

func (p *Actor) CallWait(targetPath, funcName string, arg interface{}, reply interface{}) int32

func (*Actor) Child

func (p *Actor) Child() cfacade.IActorChild

func (*Actor) Event

func (p *Actor) Event() IEvent

func (*Actor) Exit

func (p *Actor) Exit()

func (*Actor) LastAt added in v1.3.1

func (p *Actor) LastAt() int64

LastAt second

func (*Actor) Local

func (p *Actor) Local() IMailBox

func (*Actor) Path

func (p *Actor) Path() *cfacade.ActorPath

func (*Actor) PathString added in v1.3.1

func (p *Actor) PathString() string

func (*Actor) PostEvent

func (p *Actor) PostEvent(data cfacade.IEventData)

func (*Actor) PostLocal

func (p *Actor) PostLocal(m *cfacade.Message)

func (*Actor) PostRemote

func (p *Actor) PostRemote(m *cfacade.Message)

func (*Actor) Remote

func (p *Actor) Remote() IMailBox

func (*Actor) State

func (p *Actor) State() State

func (*Actor) System

func (p *Actor) System() *System

func (*Actor) Timer

func (p *Actor) Timer() ITimer

type Base

type Base struct {
	Actor
}

func (*Base) AliasID

func (p *Base) AliasID() string

func (*Base) NewChildPath added in v1.3.1

func (p *Base) NewChildPath(actorID, childID interface{}) string

func (*Base) NewMyChildPath added in v1.3.4

func (p *Base) NewMyChildPath(childID interface{}) string

func (*Base) NewNodePath added in v1.3.4

func (p *Base) NewNodePath(actorID interface{}) string

func (*Base) NewPath added in v1.3.1

func (p *Base) NewPath(nodeID, actorID interface{}) string

func (*Base) OnFindChild

func (*Base) OnFindChild(_ *cfacade.Message) (cfacade.IActor, bool)

OnFindChild 寻找子Actor时触发该函数.开发者可以自定义创建子Actor

func (*Base) OnInit

func (*Base) OnInit()

OnInit Actor初始化前触发该函数

func (*Base) OnLocalReceived

func (*Base) OnLocalReceived(_ *cfacade.Message) (next bool, invoke bool)

OnLocalReceived Actor收到Local消息时触发该函数

func (*Base) OnRemoteReceived

func (*Base) OnRemoteReceived(_ *cfacade.Message) (next bool, invoke bool)

OnRemoteReceived Actor收到Remote消息时触发该函数

func (*Base) OnStop

func (*Base) OnStop()

OnStop Actor停止前触发该函数

type Component added in v1.3.1

type Component struct {
	cfacade.Component
	*System
	// contains filtered or unexported fields
}

func New added in v1.3.1

func New() *Component

func (*Component) Add added in v1.3.1

func (c *Component) Add(actors ...cfacade.IActorHandler)

func (*Component) Init added in v1.3.1

func (c *Component) Init()

func (*Component) Name added in v1.3.1

func (c *Component) Name() string

func (*Component) OnAfterInit added in v1.3.1

func (c *Component) OnAfterInit()

func (*Component) OnStop added in v1.3.1

func (c *Component) OnStop()

type IActorLoader

type IActorLoader interface {
	// contains filtered or unexported methods
}

type IEvent

type IEvent interface {
	Register(name string, fn IEventFunc)     // 注册事件
	Registers(names []string, fn IEventFunc) // 注册多个事件
	Unregister(name string)                  // 注销事件
}

type IEventFunc

type IEventFunc func(cfacade.IEventData) // 接收事件数据时的处理函数

type IMailBox

type IMailBox interface {
	Register(funcName string, fn interface{}) // 注册执行函数
	GetFuncInfo(funcName string) (*creflect.FuncInfo, bool)
}

type ITimer

type ITimer interface {
	Add(d time.Duration, fn func(), async ...bool) uint64                   // 添加定时器,循环执行
	AddOnce(d time.Duration, fn func(), async ...bool) uint64               // 添加定时器,执行一次
	AddFixedHour(hour, minute, second int, fn func(), async ...bool) uint64 // 固定x小时x分x秒,循环执行
	AddFixedMinute(minute, second int, fn func(), async ...bool) uint64     // 固定x分x秒,循环执行
	AddSchedule(s ITimerSchedule, f func(), async ...bool) uint64           // 添加自定义调度
	Remove(id uint64)                                                       // 移除定时器
	RemoveAll()                                                             // 移除所有定时器
}

type ITimerSchedule added in v1.3.1

type ITimerSchedule interface {
	Next(time.Time) time.Time
}

type State

type State int
var (
	InitState   State = 0
	WorkerState State = 1
	FreeState   State = 2
	StopState   State = 3
)

type System

type System struct {
	// contains filtered or unexported fields
}

System Actor系统

func NewSystem

func NewSystem() *System

func (*System) Call

func (p *System) Call(source, target, funcName string, arg interface{}) int32

Call 发送远程消息(不回复)

func (*System) CallWait

func (p *System) CallWait(source, target, funcName string, arg interface{}, reply interface{}) int32

CallWait 发送远程消息(等待回复)

func (*System) CreateActor

func (p *System) CreateActor(id string, handler cfacade.IActorHandler) (cfacade.IActor, error)

CreateActor 创建Actor

func (*System) GetActor

func (p *System) GetActor(id string) (*Actor, bool)

GetActor 根据ActorID获取*actor

func (*System) GetChildActor added in v1.3.6

func (p *System) GetChildActor(actorID, childID string) (*Actor, bool)

func (*System) GetIActor

func (p *System) GetIActor(id string) (cfacade.IActor, bool)

GetIActor 根据ActorID获取IActor

func (*System) NodeId

func (p *System) NodeId() string

func (*System) PostEvent

func (p *System) PostEvent(data cfacade.IEventData)

PostEvent 提交事件

func (*System) PostLocal

func (p *System) PostLocal(m *cfacade.Message) bool

PostLocal 提交本地消息

func (*System) PostRemote

func (p *System) PostRemote(m *cfacade.Message) bool

PostRemote 提交远程消息

func (*System) SetApp added in v1.3.1

func (p *System) SetApp(app cfacade.IApplication)

func (*System) SetArrivalTimeout added in v1.3.1

func (p *System) SetArrivalTimeout(t int64)

func (*System) SetCallTimeout added in v1.3.1

func (p *System) SetCallTimeout(d time.Duration)

func (*System) SetExecutionTimeout added in v1.3.1

func (p *System) SetExecutionTimeout(t int64)

func (*System) SetLocalInvoke

func (p *System) SetLocalInvoke(fn cfacade.InvokeFunc)

func (*System) SetRemoteInvoke

func (p *System) SetRemoteInvoke(fn cfacade.InvokeFunc)

func (*System) Stop added in v1.3.1

func (p *System) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL