actor

package
v0.0.0-...-8a3f4ec Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RestartPolicyAlways = 0
	RestartPolicyNever  = 1

	StatusAlive   = 0
	StatusStopped = 1
)

Variables

View Source
var (
	ErrDidNotReply = errors.New("did not reply")
)

Functions

func GetMessage

func GetMessage[T any](m *Message) (T, error)

func GetReply

func GetReply[T any](resp *Resp) (T, error)

func NewMessageWithReply

func NewMessageWithReply[T any](v T) (*Message, *Resp, error)

Types

type Actor

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

func NewActor

func NewActor(handle Handle) *Actor

func (*Actor) Run

func (a *Actor) Run(s *supervisor)

func (*Actor) Send

func (a *Actor) Send(message *Message)

func (*Actor) Stop

func (a *Actor) Stop()

type Broadcast

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

func NewBroadcast

func NewBroadcast(actors ...string) *Broadcast

func (*Broadcast) Run

func (b *Broadcast) Run(s *supervisor)

func (*Broadcast) Send

func (b *Broadcast) Send(message *Message)

func (*Broadcast) Stop

func (b *Broadcast) Stop()

type Config

type Config struct {
	Name          string
	Actor         actorInterface
	Max           int
	RestartPolicy int
	Retries       int
}

type Context

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

func (*Context) Info

func (m *Context) Info(format string, v ...interface{})

func (*Context) Name

func (m *Context) Name() string

func (*Context) Send

func (m *Context) Send(dest string, message *Message)

type Handle

type Handle interface {
	Handle(*Context, *Message) error
}

type Message

type Message struct {
	Data     []byte
	Sender   string
	Attempts int
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage[T any](v T) *Message

func (*Message) ReplyTo

func (m *Message) ReplyTo(reply *Reply)

func (*Message) WantsReply

func (m *Message) WantsReply() bool

type Reply

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

func NewReply

func NewReply[T any](data T) (*Reply, error)

func NewReplyWithError

func NewReplyWithError(err error) *Reply

func (*Reply) Data

func (r *Reply) Data() []byte

type Resp

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

type Scalar

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

func NewScalar

func NewScalar(handle Handle, count int) *Scalar

func (*Scalar) Run

func (a *Scalar) Run(s *supervisor)

func (*Scalar) Send

func (a *Scalar) Send(message *Message)

func (*Scalar) Stop

func (a *Scalar) Stop()

type System

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

func NewSystem

func NewSystem(configs ...*Config) *System

func (*System) Context

func (c *System) Context() *Context

func (*System) GetConn

func (c *System) GetConn(name string) (actorInterface, bool)

func (*System) Start

func (c *System) Start()

func (*System) Stop

func (c *System) Stop()

func (*System) Wait

func (c *System) Wait()

Jump to

Keyboard shortcuts

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