cherryActor

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 15 Imported by: 15

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.")
	ErrNotChildActorID           = cerror.Error("Not child actorID")
	ErrActorPathTell             = cerror.Error("Target Path tell error.")
)

Functions

This section is empty.

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{}) error

func (*Actor) CallWait

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

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) Local

func (p *Actor) Local() *mailbox

func (*Actor) Path

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

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() *mailbox

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) 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 IActorLoader

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

type IEvent

type IEvent interface {
	Register(name string, fn IEventFunc) // 注册事件
	Unregister(name string)              // 注销事件
}

type IEventFunc

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

type IMailBox

type IMailBox interface {
	Register(funcName string, fn interface{}) // 注册执行函数
}

type ITask

type ITask interface {
	RunTask(fn func())
}

type ITimer

type ITimer interface {
	Add(cmd func(dt time.Duration), endAt time.Time, count ...int) (id string)      // 根据结束时间添加定时器
	AddEveryDay(cmd func(dt time.Duration), hour, minutes, seconds int) (id string) // 添加每天定时器
	AddEveryHour(cmd func(dt time.Duration), minutes, seconds int) (id string)      // 添加每小时定时器
	AddDuration(cmd func(dt time.Duration), duration time.Duration) (id string)     // 根据指定的时间截添加定时器
	Remove(id string)                                                               // 移除定时器
}

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(app cfacade.IApplication) *System

func (*System) Call

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

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

func (*System) CallWait

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

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) GetIActor

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

GetIActor 根据ActorID获取IActor

func (*System) NodeId

func (p *System) NodeId() string

func (*System) OnStop

func (p *System) OnStop()

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) SetLocalInvoke

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

func (*System) SetRemoteInvoke

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

func (*System) SetTellTimeout

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

Jump to

Keyboard shortcuts

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