actor

package
v0.0.0-...-2b6943d Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASF_NULL     = iota
	ASF_RUN      = iota
	ASF_STOPPED  = iota
	ASF_STOPPING = iota
)
View Source
const (
	MAIL_BOX_SIZE = 100
	//报警阈值
	INBOX_THRESHOLD = 30
	TICK_INTERVAL   = 500 * time.Millisecond
	EXEC_TIMEOUT    = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	Init()
	Start()
	Resume()
	Stop()
	Wait()
	Exec(context.Context, func() (interface{}, error)) (interface{}, error)
	Push(context.Context, func() (interface{}, error)) error
	GetState() int32
	SetName(string)

	Actor() Actor
	OnClose(closeCallback)
	OnTick(tickCallback)

	OnEvent(Event, evtCallback)
	EmitEvt(context.Context, Event, interface{})

	AfterFunc(time.Duration, bool, func()) *timer.Timer
	EnableParallel() //并发执行任务
}

type Event

type Event uint32

type Group

type Group interface {
	GetActor(Id uint64) Actor
	AddActor(Id uint64, ac Actor)
	DelActor(Id uint64)
	GetOwner() Actor
	Each(func(uint64, Actor))
	Stop()
	Wait()
	Count() int
}

func NewGroup

func NewGroup(owner Actor) Group

func NewSafeGroup

func NewSafeGroup(owner Actor) Group

type Impl

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

func (*Impl) Actor

func (a *Impl) Actor() Actor

func (*Impl) AfterFunc

func (a *Impl) AfterFunc(d time.Duration, repeat bool, fn func()) *timer.Timer

func (*Impl) EmitEvt

func (a *Impl) EmitEvt(ctx context.Context, evt Event, data interface{})

func (*Impl) EnableParallel

func (a *Impl) EnableParallel()

func (*Impl) Exec

func (a *Impl) Exec(ctx context.Context, fn func() (interface{}, error)) (interface{}, error)

func (*Impl) GetState

func (a *Impl) GetState() int32

func (*Impl) Init

func (a *Impl) Init()

func (*Impl) OnClose

func (a *Impl) OnClose(cb closeCallback)

func (*Impl) OnEvent

func (a *Impl) OnEvent(evt Event, cb evtCallback)

func (*Impl) OnTick

func (a *Impl) OnTick(cb tickCallback)

func (*Impl) Push

func (a *Impl) Push(ctx context.Context, fn func() (interface{}, error)) error

func (*Impl) Resume

func (a *Impl) Resume()

func (*Impl) SetName

func (a *Impl) SetName(name string)

func (*Impl) SetState

func (a *Impl) SetState(state int32)

func (*Impl) Start

func (a *Impl) Start()

func (*Impl) Stop

func (a *Impl) Stop()

func (*Impl) Wait

func (a *Impl) Wait()

type Job

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

func NewJob

func NewJob(name, router string, fn func() (interface{}, error), wait bool) *Job

func (*Job) Done

func (j *Job) Done() <-chan JobRet

func (*Job) IsRunning

func (j *Job) IsRunning() bool

func (*Job) Run

func (j *Job) Run()

type JobRet

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

Jump to

Keyboard shortcuts

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