actor

package
v0.0.0-...-1c5f5a9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDLE int32 = iota
	RUNNING
)
View Source
const LocalLookupAddr = "local"

Variables

View Source
var (
	ErrInvalidLength        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflow          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
)
View Source
var File_actor_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Base

type Base interface {
	PID() *PID
	Context() *Context
	Producer() Producer
}

type Config

type Config struct {
	PIDSeparator string
}

type Context

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

func (*Context) Child

func (slf *Context) Child(id string) *PID

func (*Context) Children

func (slf *Context) Children() []*PID

func (*Context) Engine

func (slf *Context) Engine() *Engine

func (*Context) Forward

func (slf *Context) Forward(pid *PID)

func (*Context) GetPID

func (slf *Context) GetPID(name string, tags ...string) *PID

func (*Context) Message

func (slf *Context) Message() any

func (*Context) PID

func (slf *Context) PID() *PID

func (*Context) Parent

func (slf *Context) Parent() *PID

func (*Context) Receiver

func (slf *Context) Receiver() Receiver

func (*Context) Request

func (slf *Context) Request(pid *PID, msg any, timeout time.Duration) *Response

func (*Context) Response

func (slf *Context) Response(msg any)

func (*Context) Send

func (slf *Context) Send(pid *PID, msg any)

Send 发送消息

func (*Context) SendRepeat

func (slf *Context) SendRepeat(pid *PID, msg any, interval time.Duration) SendRepeater

func (*Context) Sender

func (slf *Context) Sender() *PID

func (*Context) SpawnChild

func (slf *Context) SpawnChild(producer Producer, name string, opts ...Option) *PID

func (*Context) SpawnChildFunc

func (slf *Context) SpawnChildFunc(fn func(ctx *Context), name string, opts ...Option) *PID

type DeadLetter

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

func NewDeadLetter

func NewDeadLetter(eventStream *EventStream) *DeadLetter

func (*DeadLetter) Invoke

func (slf *DeadLetter) Invoke(envelopes []Envelope)

func (*DeadLetter) PID

func (slf *DeadLetter) PID() *PID

func (*DeadLetter) Send

func (slf *DeadLetter) Send(target *PID, message any, sender *PID)

func (*DeadLetter) Shutdown

func (slf *DeadLetter) Shutdown(wg *sync.WaitGroup)

func (*DeadLetter) Start

func (slf *DeadLetter) Start()

type Engine

type Engine struct {
	EventStream *EventStream
	Registry    *Registry
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(config ...Config) *Engine

func (*Engine) Address

func (slf *Engine) Address() string

func (*Engine) Poison

func (slf *Engine) Poison(pid *PID, wg ...*sync.WaitGroup)

func (*Engine) Request

func (slf *Engine) Request(pid *PID, message any, timeout time.Duration) *Response

func (*Engine) Send

func (slf *Engine) Send(pid *PID, msg any)

func (*Engine) SendLocal

func (slf *Engine) SendLocal(target *PID, msg any, sender *PID)

func (*Engine) SendRepeat

func (slf *Engine) SendRepeat(pid *PID, msg any, interval time.Duration) SendRepeater

func (*Engine) SendWithSender

func (slf *Engine) SendWithSender(pid *PID, msg any, sender *PID)

func (*Engine) Spawn

func (slf *Engine) Spawn(producer Producer, name string, opts ...Option) *PID

func (*Engine) SpawnFunc

func (slf *Engine) SpawnFunc(fn func(*Context), id string, opts ...Option) *PID

func (*Engine) SpawnProc

func (slf *Engine) SpawnProc(proc Processor) *PID

func (*Engine) WithRemoter

func (slf *Engine) WithRemoter(remoter Remoter)

type Envelope

type Envelope struct {
	Message any
	Sender  *PID
}

func (*Envelope) GetMessage

func (slf *Envelope) GetMessage() any

func (*Envelope) GetSender

func (slf *Envelope) GetSender() *PID

type EventActivation

type EventActivation struct{ PID *PID }

type EventDeadLetter

type EventDeadLetter struct {
	Target  *PID
	Message any
	Sender  *PID
}

type EventFunc

type EventFunc func(event any)

type EventStream

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

func NewEventStream

func NewEventStream() *EventStream

func (*EventStream) Len

func (slf *EventStream) Len() int

func (*EventStream) Publish

func (slf *EventStream) Publish(msg any)

func (*EventStream) Subscribe

func (slf *EventStream) Subscribe(fn EventFunc) *EventSub

func (*EventStream) Unsubscribe

func (slf *EventStream) Unsubscribe(sub *EventSub)

type EventSub

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

type EventTermination

type EventTermination struct{ PID *PID }

type Inbox

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

func NewInbox

func NewInbox[T constraints.Signed](size T) *Inbox

func (*Inbox) Send

func (slf *Inbox) Send(env Envelope)

func (*Inbox) Start

func (slf *Inbox) Start(processor Processor)

func (*Inbox) Stop

func (slf *Inbox) Stop() error

type InternalError

type InternalError struct {
	From string
	Err  error
}

type MiddlewareFunc

type MiddlewareFunc = func(ReceiveFunc) ReceiveFunc

type Option

type Option func(*Options)

func WithInboxSize

func WithInboxSize(size int) Option

func WithMaxRestarts

func WithMaxRestarts(n int) Option

func WithMiddleware

func WithMiddleware(middleware ...MiddlewareFunc) Option

func WithRestartDelay

func WithRestartDelay(delay time.Duration) Option

func WithTags

func WithTags(tags ...string) Option

type Options

type Options struct {
	Producer     Producer
	Name         string
	Tags         []string
	MaxRestarts  int32
	RestartDelay time.Duration
	InboxSize    int
	Middleware   []MiddlewareFunc
}

func DefaultOpts

func DefaultOpts(producer Producer) Options

type PID

type PID struct {
	Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	ID      string `protobuf:"bytes,2,opt,name=ID,proto3" json:"ID,omitempty"`
	// contains filtered or unexported fields
}

func NewPID

func NewPID(address, id string, tags ...string) *PID

func (*PID) Child

func (slf *PID) Child(id string, tags ...string) *PID

func (*PID) CloneMessageVT

func (m *PID) CloneMessageVT() proto.Message

func (*PID) CloneVT

func (m *PID) CloneVT() *PID

func (*PID) Descriptor deprecated

func (*PID) Descriptor() ([]byte, []int)

Deprecated: Use PID.ProtoReflect.Descriptor instead.

func (*PID) EqualMessageVT

func (this *PID) EqualMessageVT(thatMsg proto.Message) bool

func (*PID) EqualVT

func (this *PID) EqualVT(that *PID) bool

func (*PID) Equals

func (slf *PID) Equals(other *PID) bool

func (*PID) GetAddress

func (x *PID) GetAddress() string

func (*PID) GetID

func (x *PID) GetID() string

func (*PID) HasTag

func (slf *PID) HasTag(tag string) bool

func (*PID) LookupKey

func (slf *PID) LookupKey() uint64

func (*PID) MarshalToSizedBufferVT

func (m *PID) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*PID) MarshalToSizedBufferVTStrict

func (m *PID) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*PID) MarshalToVT

func (m *PID) MarshalToVT(dAtA []byte) (int, error)

func (*PID) MarshalToVTStrict

func (m *PID) MarshalToVTStrict(dAtA []byte) (int, error)

func (*PID) MarshalVT

func (m *PID) MarshalVT() (dAtA []byte, err error)

func (*PID) MarshalVTStrict

func (m *PID) MarshalVTStrict() (dAtA []byte, err error)

func (*PID) ProtoMessage

func (*PID) ProtoMessage()

func (*PID) ProtoReflect

func (x *PID) ProtoReflect() protoreflect.Message

func (*PID) Reset

func (x *PID) Reset()

func (*PID) SizeVT

func (m *PID) SizeVT() (n int)

func (*PID) String

func (slf *PID) String() string

func (*PID) UnmarshalVT

func (m *PID) UnmarshalVT(dAtA []byte) error

type Processor

type Processor interface {
	Start()
	PID() *PID
	Send(receiver *PID, message any, sender *PID)
	Invoke(envelopes []Envelope)
	Shutdown(wg *sync.WaitGroup)
}

type Producer

type Producer func() Receiver

type ReceiveFunc

type ReceiveFunc = func(*Context)

type Receiver

type Receiver interface {
	Receive(*Context)
}

type Registry

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

func (*Registry) Remove

func (slf *Registry) Remove(pid *PID)

type Remoter

type Remoter interface {
	Start()
	Send(target *PID, msg any, sender *PID)
	Address() string
}

type Response

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

func NewResponse

func NewResponse(engine *Engine, timeout time.Duration) *Response

func (*Response) Invoke

func (slf *Response) Invoke([]Envelope)

func (*Response) PID

func (slf *Response) PID() *PID

func (*Response) Result

func (slf *Response) Result() (any, error)

func (*Response) Send

func (slf *Response) Send(_ *PID, message any, _ *PID)

func (*Response) Shutdown

func (slf *Response) Shutdown(*sync.WaitGroup)

func (*Response) Start

func (slf *Response) Start()

type Scheduler

type Scheduler interface {
	Schedule(fn func())
	Throughput() int
}

func NewScheduler

func NewScheduler(throughput int) Scheduler

type SendRepeater

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

type Started

type Started struct{}

type Stopped

type Stopped struct{}

Jump to

Keyboard shortcuts

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