actor

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: GPL-3.0 Imports: 21 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultSysAddr = ":8888"
)
View Source
const DefaultTimeout = time.Second * 10

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 Id, handler spawnActor, opt ...Option) *actor

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

Types

type Actor added in v1.0.4

type Actor interface {
	ID() string
	System() *System
	Exit()
	Drain(afterDrained ...func())
	CallLua(name string, ret int, args ...lua.LValue) []lua.LValue

	Timer
	Sender
}

type Base

type Base struct {
	Actor
}

func (*Base) OnHandle added in v1.3.0

func (s *Base) OnHandle(msg Message)

func (*Base) OnInit

func (s *Base) OnInit()

func (*Base) OnStop

func (s *Base) OnStop() bool

type EvActorSubMqFin added in v1.3.4

type EvActorSubMqFin struct {
	ActorId Id
}

type EvClusterUpdate added in v1.0.7

type EvClusterUpdate struct {
	ActorId Id
	Host    string
	Add     bool
}

type EvDelActor added in v1.2.16

type EvDelActor struct {
	ActorId     Id
	Publish     bool
	FromCluster bool
}

type EvNewActor added in v1.2.16

type EvNewActor struct {
	ActorId     Id
	Publish     bool
	FromCluster bool
}

type EvSessionClosed added in v1.2.16

type EvSessionClosed struct {
	PeerHost string
}

type EvSessionOpened added in v1.2.16

type EvSessionOpened struct {
	PeerHost string
}

type Handler added in v1.2.21

type Handler interface{}

type Id added in v1.2.21

type Id = string

type Message added in v1.3.0

type Message interface {
	GetSourceId() Id
	GetTargetId() Id
	GetRequestId() string
	GetMsgName() string
	RawMsg() interface{}
	String() string
	Free()
}

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 ReqMsgDrain added in v1.2.21

type ReqMsgDrain struct{}

type RequestId added in v1.3.0

type RequestId string

func (RequestId) Parse added in v1.3.0

func (r RequestId) Parse() (sourceId string, targetId string, sourceAddr string, ok bool)

func (RequestId) String added in v1.3.0

func (r RequestId) String() string

func (RequestId) Valid added in v1.3.0

func (r RequestId) Valid() bool

type RespMsgDrain added in v1.2.21

type RespMsgDrain struct{ Err error }

type Sender added in v1.1.1

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

type System

type System struct {
	Stopped 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

Add startup a new actor

func (*System) Address

func (s *System) Address() string

func (*System) CancelAll

func (ed *System) CancelAll(actorId Id)

func (*System) CancelEvent

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

func (*System) Cluster added in v1.2.18

func (s *System) Cluster() *actor

func (*System) DispatchEvent

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

func (*System) LocalActor added in v1.2.19

func (s *System) LocalActor(actorId string) *actor

func (*System) OnEvent added in v1.2.21

func (ed *System) OnEvent(actorId Id, callback Handler)

func (*System) ProtoIndex added in v1.2.2

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

func (*System) RequestWait added in v1.2.18

func (s *System) RequestWait(targetId string, msg interface{}, timeout ...time.Duration) (resp interface{}, err error)

RequestWait sync request

func (*System) Send

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

Send try to send the message to target

func (*System) SetCluster

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

func (*System) Stop

func (s *System) Stop()

func (*System) WaiterId added in v1.2.21

func (s *System) WaiterId() string

type SystemOption

type SystemOption func(*System) error

func Addr

func Addr(addr string) SystemOption

func LogLevel added in v1.3.6

func LogLevel(level logger.Level) SystemOption

func Name added in v1.3.9

func Name(name string) SystemOption

func Output added in v1.3.6

func Output(out io.Writer) SystemOption

func ProtoIndex added in v1.2.0

func ProtoIndex(pi *tools.ProtoIndex) SystemOption

ProtoIndex index proto struct

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

type TmpActor added in v1.2.18

type TmpActor struct {
	Base
	Init   func()
	Stop   func() bool
	Handle func(msg Message)
}

func (*TmpActor) OnHandle added in v1.3.0

func (s *TmpActor) OnHandle(msg Message)

func (*TmpActor) OnInit added in v1.2.18

func (s *TmpActor) OnInit()

func (*TmpActor) OnStop added in v1.2.21

func (s *TmpActor) OnStop() bool

Jump to

Keyboard shortcuts

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