actor

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 19 Imported by: 5

Documentation

Index

Constants

View Source
const DefaultTimeout = time.Second * 5

Variables

This section is empty.

Functions

func LDebug

func LDebug(l *lua.LState) int

func LError

func LError(l *lua.LState) int

func LGoVersion

func LGoVersion(l *lua.LState) int

func LWarn

func LWarn(l *lua.LState) int

func New

func New(id string, handler spawnActor, op ...Option) *actor

New new actor id is invalid if contain '@' or '$'

func ParseRequestId

func ParseRequestId(requestId string) (sourceId string, targetId string, sourceAddr string, ok bool)

Types

type Actor added in v1.0.4

type Actor interface {
	//core
	ID() string
	System() *System
	Exit()

	Timer
	Sender

	//lua
	CallLua(name string, ret int, args ...lua.LValue) []lua.LValue
	//cmd
	RegistCmd(cmd string, fn func(...string), usage ...string)
}

type Base

type Base struct {
	Actor
}

func (*Base) OnHandleEvent

func (s *Base) OnHandleEvent(event interface{})

func (*Base) OnHandleMessage

func (s *Base) OnHandleMessage(sourceId, targetId string, msg interface{})

func (*Base) OnHandleRequest

func (s *Base) OnHandleRequest(sourceId, targetId, requestId string, msg interface{}) (respErr error)

func (*Base) OnInit

func (s *Base) OnInit()

func (*Base) OnStop

func (s *Base) OnStop() bool

type Cmder added in v1.1.12

type Cmder interface {
	Start(actorSystem *System)
	RegistCmd(actorId, cmd string, f func(...string), usage ...string)
}

type EvClusterUpdate added in v1.0.7

type EvClusterUpdate struct {
	ActorId string
	Host    string
	Add     bool
}

type EvDelactor added in v1.0.7

type EvDelactor struct {
	ActorId     string
	Publish     bool
	FromCluster bool
}

type EvNewactor added in v1.0.7

type EvNewactor struct {
	ActorId     string
	Publish     bool
	FromCluster bool
}

type EvSessionclosed added in v1.0.7

type EvSessionclosed struct {
	PeerHost string
}

type EvSessionopened added in v1.0.7

type EvSessionopened struct {
	PeerHost string
}

type Option added in v1.1.10

type Option func(*actor)

func SetLocalized

func SetLocalized() Option

func SetLua

func SetLua(path string) Option

func SetMailBoxSize

func SetMailBoxSize(boxSize int) Option

type Sender added in v1.1.1

type Sender interface {
	Send(targetId string, msg interface{}) error
	Request(targetId string, msg interface{}, timeout ...time.Duration) (req *request)
	RequestWait(targetId string, msg interface{}, timeout ...time.Duration) (result interface{}, err error)
	Response(requestId string, msg interface{}) error
}

type System

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

func NewSystem

func NewSystem(op ...SystemOption) (*System, error)

func (*System) Add added in v1.1.13

func (s *System) Add(actor *actor) error

func (*System) Address

func (s *System) Address() string

func (*System) CancelAll

func (ed *System) CancelAll(actorId string)

CancelAll 取消actor事件

func (*System) CancelEvent

func (ed *System) CancelEvent(actorId string, events ...interface{}) error

CancelEvent 取消actor事件

func (*System) DispatchEvent

func (ed *System) DispatchEvent(sourceId string, event interface{})

DispatchEvent 事件触发

func (*System) Exist added in v1.2.9

func (s *System) Exist(actorId string) bool

func (*System) ProtoIndex added in v1.2.2

func (s *System) ProtoIndex() *tools.ProtoIndex

func (*System) RegistEvent

func (ed *System) RegistEvent(actorId string, events ...interface{}) error

RegistEvent 注册actor事件

func (*System) Send

func (s *System) Send(sourceId, targetId, requestId string, msg interface{}) error

Send msg send to target,if target not exist in local cache msg shall send to cluster

func (*System) SetCluster

func (s *System) SetCluster(act *actor)

func (*System) Stop

func (s *System) Stop()

type SystemOption

type SystemOption func(*System) error

func Addr

func Addr(addr string) SystemOption

func ProtoIndex added in v1.2.0

func ProtoIndex(pi *tools.ProtoIndex) SystemOption

ProtoIndex index proto struct

func WithCMD

func WithCMD(cmd Cmder) SystemOption

设置Actor监听的端口

type Timer added in v1.1.1

type Timer interface {
	AddTimer(timeId string, endAt time.Time, callback func(dt time.Duration), triggerCount ...int) string
	CancelTimer(timerId string)
}

Jump to

Keyboard shortcuts

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