actor

package
v0.0.0-...-2692626 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Behavior

type Behavior struct {
}

type IActor

type IActor[TKey comparable] interface {
	GetKey() TKey
}

IActor 是 Actor 接口

type IMsg

type IMsg interface {
}

IMsg 是消息接口

type Mgr

type Mgr[TKey comparable] struct {
	// contains filtered or unexported fields
}

Mgr 管理 IActor 的简单系统

func NewMgr

func NewMgr[TKey comparable]() *Mgr[TKey]

NewMgr 创建 Mgr 实例

func (*Mgr[TKey]) DeleteActor

func (p *Mgr[TKey]) DeleteActor(ctx context.Context, key TKey)

DeleteActor 从系统中删除指定的 IActor

func (*Mgr[TKey]) SendMessage

func (p *Mgr[TKey]) SendMessage(key TKey, msg IMsg)

SendMessage 向指定 IActor 发送消息

func (*Mgr[TKey]) SpawnActor

func (p *Mgr[TKey]) SpawnActor(ctx context.Context, key TKey, options ...*Options)

SpawnActor 创建一个新的 IActor 并添加到系统中

type Msg

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

Msg 是 IMsg 的实现

type Normal

type Normal[TKey comparable] struct {
	// contains filtered or unexported fields
}

func NewNormal

func NewNormal[TKey comparable](ctx context.Context, key TKey, options ...*Options) *Normal[TKey]

func (*Normal[TKey]) GetKey

func (p *Normal[TKey]) GetKey() TKey

type OnDefaultHandler

type OnDefaultHandler func(msg *Msg) error

type Options

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

Options contains Options to configure instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.

func NewOptions

func NewOptions() *Options

NewOptions 新的Options

func (*Options) WithActorChannelSize

func (p *Options) WithActorChannelSize(actorChannelSize uint32) *Options

func (*Options) WithDefaultHandler

func (p *Options) WithDefaultHandler(defaultHandler OnDefaultHandler) *Options

type State

type State struct {
}

Jump to

Keyboard shortcuts

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