actorlayer

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package actorlayer provides provider-agnostic typed actor execution primitives.

Actorlayer is product-agnostic infrastructure. It does not depend on Google ADK, Balda, Telegram, JetStream, NATS, MCP, model providers, workspace policy, queue providers, or product-specific task/projection lifecycles. Those concerns belong to adapter and product integration packages.

The package owns local actor mechanics: addressable refs, typed envelopes, per-actor mailboxes, Tell and Ask messaging, lifecycle publication, supervision, dead-letter sinks, scheduling, observer hooks, and tracing hooks. A product embeds actorlayer by translating its own commands and runtime context into actorlayer refs, envelopes, and behaviors.

Runtime providers and transports are intentionally outside this package. Local workers, ADK-backed agents, command delivery, ack/retry/deadletter settlement, telemetry shaping, and persistence side effects must be adapted at the boundary instead of being embedded in actorlayer core.

Index

Examples

Constants

View Source
const (
	// DefaultMailboxCapacity is the default in-memory mailbox capacity per actor.
	DefaultMailboxCapacity = 64
	// DefaultAskTimeout is the default timeout used by Ask when none is provided.
	DefaultAskTimeout = 30 * time.Second
)
View Source
const LifecycleTopic = "actor.lifecycle"

LifecycleTopic is the pub/sub topic used for actor lifecycle notifications.

Variables

View Source
var (
	// ErrMailboxFull indicates a bounded mailbox rejected an enqueue because it is full.
	ErrMailboxFull = errors.New("actorlayer: mailbox full")
	// ErrMailboxClosed indicates a mailbox is no longer accepting messages.
	ErrMailboxClosed = errors.New("actorlayer: mailbox closed")
	// ErrMailboxDrop indicates a mailbox drop policy discarded a message.
	ErrMailboxDrop = errors.New("actorlayer: message dropped")
	// ErrActorNotFound indicates the target actor reference is unknown to the system.
	ErrActorNotFound = errors.New("actorlayer: actor not found")
	// ErrAskTimeout indicates Ask did not receive a reply before timeout.
	ErrAskTimeout = errors.New("actorlayer: ask timeout")
	// ErrRateLimited indicates the system rejected a Tell due to rate limiting.
	ErrRateLimited = errors.New("actorlayer: rate limited")
	// ErrScheduleCanceled indicates a scheduled send was canceled before delivery.
	ErrScheduleCanceled = errors.New("actorlayer: scheduled delivery canceled")
	// ErrShuttingDown indicates the system is shutting down and not accepting new work.
	ErrShuttingDown = errors.New("actorlayer: shutting down")
	// ErrUnhandled indicates a behavior intentionally did not handle the payload.
	ErrUnhandled = errors.New("actorlayer: unhandled message")
)
View Source
var (
	// ErrMessageTypeMismatch is returned when an envelope payload does not match
	// the typed actor message contract.
	ErrMessageTypeMismatch = errors.New("actorlayer: message type mismatch")
	// ErrResponseTypeMismatch is returned when AskTyped receives a response
	// payload that does not match the requested response type.
	ErrResponseTypeMismatch = errors.New("actorlayer: response type mismatch")
)

Functions

This section is empty.

Types

type Actor

type Actor[M any] interface {
	Receive(ctx Context, env TypedEnvelope[M]) error
}

Actor is a typed actor contract for one message type M.

func AdaptEventActor

func AdaptEventActor[M any](eventActor EventActor[M]) Actor[M]

AdaptEventActor converts an EventActor into a generic Actor.

func AdaptRequestActor

func AdaptRequestActor[Req any, Resp any](requestActor RequestActor[Req, Resp]) Actor[Req]

AdaptRequestActor converts RequestActor into Actor[Req] that replies to EnvelopeMeta.ReplyTo with the typed response when reply target is present.

type ActorFunc

type ActorFunc[M any] func(ctx Context, env TypedEnvelope[M]) error

ActorFunc adapts a function into Actor[M].

func (ActorFunc[M]) Receive

func (f ActorFunc[M]) Receive(ctx Context, env TypedEnvelope[M]) error

Receive executes the wrapped function.

type ActorID

type ActorID string

ActorID is a stable local identifier for an actor within one system.

type ActorRef

type ActorRef[M any] struct {
	// contains filtered or unexported fields
}

ActorRef is a typed reference to an actor expecting message type M.

func SpawnTyped

func SpawnTyped[M any](ctx context.Context, sys *System, name string, props TypedProps[M], opts ...SpawnOption) (ActorRef[M], error)

SpawnTyped creates and starts a typed actor instance.

Example
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/normahq/norma/pkg/actorlayer"
)

type addRequest struct {
	A int
	B int
}

type addResponse struct {
	Sum int
}

func main() {
	ctx := context.Background()
	sys, err := actorlayer.NewSystem(actorlayer.Config{})
	if err != nil {
		panic(err)
	}
	defer func() {
		shutdownCtx, cancel := context.WithTimeout(context.Background(), time.Second)
		defer cancel()
		_ = sys.Shutdown(shutdownCtx)
	}()

	ref, err := actorlayer.SpawnTyped[addRequest](ctx, sys, "adder", actorlayer.TypedProps[addRequest]{
		NewActor: func(actorlayer.SpawnContext) (actorlayer.Actor[addRequest], error) {
			return actorlayer.AdaptRequestActor[addRequest, addResponse](
				actorlayer.RequestActorFunc[addRequest, addResponse](func(_ actorlayer.Context, env actorlayer.TypedEnvelope[addRequest]) (addResponse, error) {
					return addResponse{Sum: env.Message.A + env.Message.B}, nil
				}),
			), nil
		},
	})
	if err != nil {
		panic(err)
	}

	resp, err := actorlayer.AskTyped[addRequest, addResponse](
		ctx,
		sys,
		ref,
		addRequest{A: 2, B: 3},
		actorlayer.WithTimeout(time.Second),
	)
	if err != nil {
		panic(err)
	}

	fmt.Println(resp.Message.Sum)
}
Output:
5

func (ActorRef[M]) ID

func (r ActorRef[M]) ID() ActorID

ID returns the actor identifier.

func (ActorRef[M]) Tell

func (r ActorRef[M]) Tell(ctx context.Context, msg M, opts ...TellOption) error

Tell sends a typed message to the actor.

func (ActorRef[M]) Untyped

func (r ActorRef[M]) Untyped() Ref

Untyped returns the underlying untyped reference.

type AskOption

type AskOption interface {
	// contains filtered or unexported methods
}

AskOption configures Ask behavior and forwarded envelope metadata.

func WithAskCorrelationID

func WithAskCorrelationID(id CorrelationID) AskOption

WithAskCorrelationID sets Ask forwarded envelope correlation id.

func WithAskFrom

func WithAskFrom(from Ref) AskOption

WithAskFrom sets sender reference on Ask forwarded envelope.

func WithAskHeader

func WithAskHeader(key, value string) AskOption

WithAskHeader sets one header on Ask forwarded envelope.

func WithAskHeaders

func WithAskHeaders(headers map[string]string) AskOption

WithAskHeaders merges headers on Ask forwarded envelope.

func WithTimeout

func WithTimeout(timeout time.Duration) AskOption

WithTimeout sets Ask timeout.

type Behavior

type Behavior interface {
	Receive(ctx Context, env Envelope) error
}

Behavior handles one envelope at a time for an actor cell.

type BoundedMailboxConfig

type BoundedMailboxConfig struct {
	Capacity   int
	FullPolicy MailboxFullPolicy
}

BoundedMailboxConfig configures bounded FIFO mailbox behavior.

type Clock

type Clock interface {
	Now() time.Time
}

Clock abstracts time for scheduling and tests.

type Config

type Config struct {
	NodeID                 string
	DefaultMailbox         MailboxFactory
	DeadLetters            DeadLetterSink
	Observer               Observer
	Tracer                 Tracer
	Supervision            SupervisorStrategy
	Clock                  Clock
	MaxActors              int
	MaxTotalQueued         int
	DefaultAskLimit        time.Duration
	TellRateLimitPerSecond int
	ShutdownPolicy         ShutdownPolicy
	ShutdownPollInterval   time.Duration
}

Config defines runtime limits and integrations for System.

type Context

type Context interface {
	context.Context

	Self() Ref
	Parent() *Ref
	Sender() *Ref

	Tell(ctx context.Context, to Ref, payload any, opts ...TellOption) error
	TellAfter(ctx context.Context, delay time.Duration, to Ref, payload any, opts ...TellOption) (Scheduled, error)
	Ask(ctx context.Context, to Ref, payload any, opts ...AskOption) (Envelope, error)

	Spawn(ctx context.Context, name string, props Props, opts ...SpawnOption) (Ref, error)
	Stop(ctx context.Context, ref Ref) error
	Watch(ctx context.Context, ref Ref) error

	State() State
	Publish(ctx context.Context, topic string, payload any) error
}

Context provides actor-local execution context for message handling.

type CorrelationID

type CorrelationID string

CorrelationID groups related envelopes across exchanges.

type DeadLetter

type DeadLetter struct {
	Envelope Envelope
	Reason   string
	Err      error
}

DeadLetter describes a delivery that could not be completed.

type DeadLetterSink

type DeadLetterSink interface {
	HandleDeadLetter(ctx context.Context, letter DeadLetter)
}

DeadLetterSink consumes failed delivery records.

type DefaultSupervisor

type DefaultSupervisor struct{}

DefaultSupervisor provides conservative failure handling defaults.

func (DefaultSupervisor) Decide

Decide chooses a directive based on panic/error class.

type Directive

type Directive int

Directive is the supervisor decision returned after a failure.

const (
	// Resume keeps the current behavior instance and continues processing.
	Resume Directive = iota
	// Restart rebuilds actor behavior using Props.NewBehavior.
	Restart
	// Stop terminates the actor.
	Stop
	// Escalate delegates the failure to a parent/superior policy.
	Escalate
)

type Envelope

type Envelope struct {
	ID            MessageID
	CorrelationID CorrelationID

	To      Ref
	From    Ref
	ReplyTo *Ref

	Headers map[string]string
	Payload any

	Deadline time.Time
	SentAt   time.Time
}

Envelope is the transport unit placed in actor mailboxes.

func Ask

func Ask(ctx context.Context, sys *System, to Ref, payload any, opts ...AskOption) (resp Envelope, err error)

Ask sends a message and waits for a reply envelope.

Example
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/normahq/norma/pkg/actorlayer"
)

func main() {
	ctx := context.Background()
	sys, err := actorlayer.NewSystem(actorlayer.Config{})
	if err != nil {
		panic(err)
	}
	defer func() {
		shutdownCtx, cancel := context.WithTimeout(context.Background(), time.Second)
		defer cancel()
		_ = sys.Shutdown(shutdownCtx)
	}()

	echoRef, err := sys.Spawn(ctx, "echo", actorlayer.Props{
		NewBehavior: func(actorlayer.SpawnContext) (actorlayer.Behavior, error) {
			return actorlayer.ReceiveFunc(func(c actorlayer.Context, env actorlayer.Envelope) error {
				if env.ReplyTo == nil {
					return nil
				}
				return c.Tell(c, *env.ReplyTo, fmt.Sprintf("echo:%v", env.Payload))
			}), nil
		},
	})
	if err != nil {
		panic(err)
	}

	reply, err := actorlayer.Ask(ctx, sys, echoRef, "ping", actorlayer.WithTimeout(time.Second))
	if err != nil {
		panic(err)
	}

	fmt.Println(reply.Payload)
}
Output:
echo:ping

type EnvelopeMeta

type EnvelopeMeta struct {
	ID            MessageID
	CorrelationID CorrelationID

	To      Ref
	From    Ref
	ReplyTo *Ref

	Headers  map[string]string
	Deadline time.Time
	SentAt   time.Time
}

EnvelopeMeta carries transport/runtime metadata for a typed envelope.

type EventActor

type EventActor[M any] interface {
	OnEvent(ctx Context, env TypedEnvelope[M]) error
}

EventActor is a semantic actor type for one-way event handling.

type EventActorFunc

type EventActorFunc[M any] func(ctx Context, env TypedEnvelope[M]) error

EventActorFunc adapts a function into EventActor[M].

func (EventActorFunc[M]) OnEvent

func (f EventActorFunc[M]) OnEvent(ctx Context, env TypedEnvelope[M]) error

OnEvent executes the wrapped function.

type Failure

type Failure struct {
	Actor   Ref
	Message Envelope
	Err     error
	Panic   any
	At      time.Time
}

Failure captures a behavior error or panic with message context.

type Mailbox

type Mailbox interface {
	Enqueue(ctx context.Context, env Envelope) error
	Dequeue(ctx context.Context) (Envelope, error)
	Len() int
	Close() error
}

Mailbox is the actor queue abstraction used by each actor cell.

type MailboxFactory

type MailboxFactory interface {
	NewMailbox(actorID ActorID) (Mailbox, error)
}

MailboxFactory creates a mailbox instance for a specific actor.

func NewBoundedMailboxFactory

func NewBoundedMailboxFactory(cfg BoundedMailboxConfig) MailboxFactory

NewBoundedMailboxFactory returns a mailbox factory backed by bounded in-memory channels.

type MailboxFullPolicy

type MailboxFullPolicy int

MailboxFullPolicy defines behavior when enqueue is attempted on a full mailbox.

const (
	// FailFast returns ErrMailboxFull when the mailbox is full.
	FailFast MailboxFullPolicy = iota
	// BlockUntilSpace blocks until space is available or context closes.
	BlockUntilSpace
	// DropNewest discards the new message when the mailbox is full.
	DropNewest
	// DropOldest removes one queued message and enqueues the new message.
	DropOldest
)

type MessageID

type MessageID string

MessageID identifies one envelope.

type NopDeadLetterSink

type NopDeadLetterSink struct{}

NopDeadLetterSink ignores all dead letters.

func (NopDeadLetterSink) HandleDeadLetter

func (NopDeadLetterSink) HandleDeadLetter(_ context.Context, _ DeadLetter)

HandleDeadLetter discards the dead letter.

type NopObserver

type NopObserver struct{}

NopObserver is a no-op Observer implementation.

func (NopObserver) OnActorSpawn

func (NopObserver) OnActorSpawn(ActorID)

OnActorSpawn records actor spawn events.

func (NopObserver) OnActorStop

func (NopObserver) OnActorStop(ActorID)

OnActorStop records actor stop events.

func (NopObserver) OnAskDone

func (NopObserver) OnAskDone(ActorID, error)

OnAskDone records Ask completion events.

func (NopObserver) OnAskStart

func (NopObserver) OnAskStart(ActorID)

OnAskStart records Ask start events.

func (NopObserver) OnDeadLetter

func (NopObserver) OnDeadLetter(DeadLetter)

OnDeadLetter records dead-letter events.

func (NopObserver) OnReceive

func (NopObserver) OnReceive(ActorID, time.Duration, error, any)

OnReceive records message receive events.

func (NopObserver) OnRestart

func (NopObserver) OnRestart(ActorID)

OnRestart records actor restart events.

func (NopObserver) OnTellEnqueue

func (NopObserver) OnTellEnqueue(ActorID)

OnTellEnqueue records Tell enqueue events.

type NopTracer

type NopTracer struct{}

NopTracer is a tracer implementation that records nothing.

func (NopTracer) Start

Start returns the input context and a no-op span.

type Observer

type Observer interface {
	OnActorSpawn(actorID ActorID)
	OnActorStop(actorID ActorID)
	OnTellEnqueue(actorID ActorID)
	OnAskStart(actorID ActorID)
	OnAskDone(actorID ActorID, err error)
	OnReceive(actorID ActorID, duration time.Duration, err error, panicValue any)
	OnRestart(actorID ActorID)
	OnDeadLetter(letter DeadLetter)
}

Observer receives runtime lifecycle and messaging callbacks from System.

type Props

type Props struct {
	Kind        string
	NewBehavior func(ctx SpawnContext) (Behavior, error)

	Mailbox    MailboxFactory
	Supervisor SupervisorStrategy
}

Props configures actor behavior construction and runtime policy.

type PublishedMessage

type PublishedMessage struct {
	Topic   string
	Payload any
}

PublishedMessage wraps topic broadcasts delivered to subscribers.

type ReceiveFunc

type ReceiveFunc func(ctx Context, env Envelope) error

ReceiveFunc adapts a function into a Behavior.

func (ReceiveFunc) Receive

func (f ReceiveFunc) Receive(ctx Context, env Envelope) error

Receive executes the wrapped function.

type Ref

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

Ref is an addressable reference to an actor.

func (Ref) Ask

func (r Ref) Ask(ctx context.Context, payload any, opts ...AskOption) (Envelope, error)

Ask sends a request and waits for a reply.

func (Ref) ID

func (r Ref) ID() ActorID

ID returns the actor identifier.

func (Ref) Tell

func (r Ref) Tell(ctx context.Context, payload any, opts ...TellOption) error

Tell sends an asynchronous message to the actor.

type RequestActor

type RequestActor[Req any, Resp any] interface {
	Handle(ctx Context, env TypedEnvelope[Req]) (Resp, error)
}

RequestActor is a semantic actor type for request-response workflows.

type RequestActorFunc

type RequestActorFunc[Req any, Resp any] func(ctx Context, env TypedEnvelope[Req]) (Resp, error)

RequestActorFunc adapts a function into RequestActor[Req, Resp].

func (RequestActorFunc[Req, Resp]) Handle

func (f RequestActorFunc[Req, Resp]) Handle(ctx Context, env TypedEnvelope[Req]) (Resp, error)

Handle executes the wrapped function.

type Scheduled

type Scheduled interface {
	// Cancel stops the scheduled delivery if it has not fired yet.
	Cancel() bool
	// Done is closed when scheduling completes, returning the final send result.
	Done() <-chan error
}

Scheduled represents a delayed message delivery.

type ShutdownPolicy

type ShutdownPolicy int

ShutdownPolicy controls how Shutdown waits for in-flight work.

const (
	// ShutdownImmediate cancels actors immediately.
	ShutdownImmediate ShutdownPolicy = iota
	// ShutdownDrain waits until actors become idle before canceling.
	ShutdownDrain
)

type Span

type Span interface {
	AddEvent(name string, attrs TraceAttrs)
	End(err error)
}

Span captures a traced operation.

type SpawnContext

type SpawnContext struct {
	Self   Ref
	Parent *Ref
}

SpawnContext contains immutable context available while creating behavior.

type SpawnOption

type SpawnOption interface {
	// contains filtered or unexported methods
}

SpawnOption configures Spawn behavior.

func WithActorID

func WithActorID(id string) SpawnOption

WithActorID sets an explicit actor id instead of generated id.

type Started

type Started struct {
	Actor Ref
}

Started is emitted when an actor cell is created and registered.

type State

type State interface {
	Get(key string) (any, bool)
	Set(key string, value any)
	Delete(key string)
}

State stores actor-private mutable key/value data.

type StatsObserver

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

StatsObserver accumulates runtime counters and durations.

func (*StatsObserver) OnActorSpawn

func (s *StatsObserver) OnActorSpawn(ActorID)

OnActorSpawn increments the actor spawn counter.

func (*StatsObserver) OnActorStop

func (s *StatsObserver) OnActorStop(ActorID)

OnActorStop increments the actor stop counter.

func (*StatsObserver) OnAskDone

func (s *StatsObserver) OnAskDone(_ ActorID, err error)

OnAskDone increments the ask-failure counter for failed asks.

func (*StatsObserver) OnAskStart

func (s *StatsObserver) OnAskStart(ActorID)

OnAskStart increments the ask-start counter.

func (*StatsObserver) OnDeadLetter

func (s *StatsObserver) OnDeadLetter(DeadLetter)

OnDeadLetter increments the dead-letter counter.

func (*StatsObserver) OnReceive

func (s *StatsObserver) OnReceive(_ ActorID, duration time.Duration, err error, panicValue any)

OnReceive updates counters and total receive duration.

func (*StatsObserver) OnRestart

func (s *StatsObserver) OnRestart(ActorID)

OnRestart increments the restart counter.

func (*StatsObserver) OnTellEnqueue

func (s *StatsObserver) OnTellEnqueue(ActorID)

OnTellEnqueue increments the enqueue counter.

func (*StatsObserver) Snapshot

func (s *StatsObserver) Snapshot() StatsSnapshot

Snapshot returns a point-in-time copy of collected stats.

type StatsSnapshot

type StatsSnapshot struct {
	ActorSpawns     int64
	ActorStops      int64
	TellEnqueues    int64
	AskStarts       int64
	AskFailures     int64
	Receives        int64
	ReceiveFailures int64
	ReceivePanics   int64
	Restarts        int64
	DeadLetters     int64
	ReceiveDurTotal time.Duration
}

StatsSnapshot contains cumulative counters collected by StatsObserver.

type Stopped

type Stopped struct {
	Actor Ref
}

Stopped is emitted when an actor begins shutdown.

type SupervisionContext

type SupervisionContext struct {
	System *System
}

SupervisionContext contains runtime context for supervisor decisions.

type SupervisorStrategy

type SupervisorStrategy interface {
	Decide(ctx SupervisionContext, failure Failure) Directive
}

SupervisorStrategy decides actor action for a message failure.

type System

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

System hosts actor cells, routing, and runtime controls.

func NewSystem

func NewSystem(cfg Config) (*System, error)

NewSystem constructs an in-memory actor runtime with defaults.

func (*System) Publish

func (s *System) Publish(ctx context.Context, topic string, payload any) error

Publish sends a payload to all current subscribers of a topic.

func (*System) Ref

func (s *System) Ref(id ActorID) Ref

Ref returns a local actor reference by id.

func (*System) Shutdown

func (s *System) Shutdown(ctx context.Context) error

Shutdown stops the system according to the configured shutdown policy.

func (*System) Spawn

func (s *System) Spawn(ctx context.Context, name string, props Props, opts ...SpawnOption) (Ref, error)

Spawn creates and starts a new actor instance.

func (*System) Stop

func (s *System) Stop(ctx context.Context, ref Ref) error

Stop requests actor termination and waits until it exits or context ends.

func (*System) Subscribe

func (s *System) Subscribe(topic string, subscriber Ref) error

Subscribe registers an actor to receive PublishedMessage values for a topic.

func (*System) Tell

func (s *System) Tell(ctx context.Context, to Ref, payload any, opts ...TellOption) (err error)

Tell enqueues an asynchronous message to an actor.

func (*System) TellAfter

func (s *System) TellAfter(ctx context.Context, delay time.Duration, to Ref, payload any, opts ...TellOption) (Scheduled, error)

TellAfter schedules a Tell delivery after delay.

func (*System) Unsubscribe

func (s *System) Unsubscribe(topic string, subscriber Ref) error

Unsubscribe removes an actor subscription for a topic.

func (*System) Watch

func (s *System) Watch(_ context.Context, watcher Ref, target Ref) error

Watch subscribes watcher to target termination notifications.

type TellOption

type TellOption interface {
	// contains filtered or unexported methods
}

TellOption configures Tell delivery metadata.

func WithCorrelationID

func WithCorrelationID(id CorrelationID) TellOption

WithCorrelationID sets envelope correlation id.

func WithDeadline

func WithDeadline(deadline time.Time) TellOption

WithDeadline sets envelope processing deadline.

func WithFrom

func WithFrom(from Ref) TellOption

WithFrom sets the sender reference on an outgoing envelope.

func WithHeader

func WithHeader(key, value string) TellOption

WithHeader sets one envelope header entry.

func WithHeaders

func WithHeaders(headers map[string]string) TellOption

WithHeaders merges envelope header entries.

func WithMessageID

func WithMessageID(id MessageID) TellOption

WithMessageID sets envelope message id.

func WithReplyTo

func WithReplyTo(replyTo Ref) TellOption

WithReplyTo sets the reply target reference on an outgoing envelope.

type Terminated

type Terminated struct {
	ActorID ActorID
}

Terminated is sent to watchers after an actor fully exits.

type ThresholdSupervisor

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

ThresholdSupervisor escalates or stops an actor after too many restart-worthy failures within the configured time window.

func NewThresholdSupervisor

func NewThresholdSupervisor(cfg ThresholdSupervisorConfig) *ThresholdSupervisor

NewThresholdSupervisor returns a supervisor that limits restart bursts.

func (*ThresholdSupervisor) Decide

func (s *ThresholdSupervisor) Decide(ctx SupervisionContext, failure Failure) Directive

Decide applies the base strategy and enforces restart thresholds.

type ThresholdSupervisorConfig

type ThresholdSupervisorConfig struct {
	Base        SupervisorStrategy
	MaxRestarts int
	Window      time.Duration
	OnExceeded  Directive
}

ThresholdSupervisorConfig configures restart-threshold based supervision.

type TraceAttrs

type TraceAttrs map[string]string

TraceAttrs is a lightweight attribute map for tracing spans and events.

type Tracer

type Tracer interface {
	Start(ctx context.Context, name string, attrs TraceAttrs) (context.Context, Span)
}

Tracer starts spans for actorlayer operations.

type TypedEnvelope

type TypedEnvelope[M any] struct {
	Meta    EnvelopeMeta
	Message M
}

TypedEnvelope is the typed message envelope presented to Actor[M].

func AskTyped

func AskTyped[Req any, Resp any](
	ctx context.Context,
	sys *System,
	to ActorRef[Req],
	msg Req,
	opts ...AskOption,
) (TypedEnvelope[Resp], error)

AskTyped sends a typed request and expects a typed response payload.

type TypedProps

type TypedProps[M any] struct {
	Kind     string
	NewActor func(ctx SpawnContext) (Actor[M], error)

	Mailbox    MailboxFactory
	Supervisor SupervisorStrategy
}

TypedProps configures a typed actor spawn.

Directories

Path Synopsis
Package engine provides a provider-neutral durable-delivery runtime core for actorlayer dispatch.
Package engine provides a provider-neutral durable-delivery runtime core for actorlayer dispatch.
Package persistence contains optional interfaces for persistent actor mailboxes and actor state stores.
Package persistence contains optional interfaces for persistent actor mailboxes and actor state stores.

Jump to

Keyboard shortcuts

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