Skip to content

ActorContext

Defined in: src/ActorContext.ts:15

Runtime API given to every Actor. Access through this.context inside an Actor subclass.

TMsg = unknown

readonly children: readonly ActorRef<unknown>[]

Defined in: src/ActorContext.ts:32

Snapshot of direct children.


readonly log: Logger

Defined in: src/ActorContext.ts:35

Logger bound to this actor’s path.


readonly parent: Option<ActorRef<unknown>>

Defined in: src/ActorContext.ts:29

Parent actor, or None for the root guardian.


readonly path: ActorPath

Defined in: src/ActorContext.ts:20

The ActorPath of this actor.


readonly self: ActorRef<TMsg>

Defined in: src/ActorContext.ts:17

A reference to this actor.


readonly sender: Option<ActorRef<unknown>>

Defined in: src/ActorContext.ts:23

The sender of the message currently being processed, or None.


readonly stashSize: number

Defined in: src/ActorContext.ts:95

Number of currently-stashed messages.


readonly system: ActorSystem

Defined in: src/ActorContext.ts:26

The enclosing ActorSystem.


readonly timers: TimerScheduler<TMsg>

Defined in: src/ActorContext.ts:103

Per-actor scheduling facade. Timers are identified by user-supplied string keys and are automatically cancelled when the actor stops.

actorOf<T>(props, name?): ActorRef<T>

Defined in: src/ActorContext.ts:38

Spawn a child actor under this one. name must be unique among siblings.

T

Props<T>

string

ActorRef<T>


actorSelection(path): ActorSelection

Defined in: src/ActorContext.ts:47

Build an ActorSelection that resolves a full-path lookup. Delegates to the enclosing ActorSystem — same semantics as system.actorSelection.

string

ActorSelection


become(behavior, discardOld?): void

Defined in: src/ActorContext.ts:65

Replace the current behaviour. When discardOld is false, the previous behaviour is pushed onto a stack and can be restored via unbecome().

Receive<TMsg>

boolean

void


cancelReceiveTimeout(): void

Defined in: src/ActorContext.ts:77

Disable the receive timeout.

void


cancelThrottle(): void

Defined in: src/ActorContext.ts:125

Remove any active throttle, restoring unlimited dequeue rate.

void


child(name): Option<ActorRef<unknown>>

Defined in: src/ActorContext.ts:41

Look up a direct child by name. None if no such child exists.

string

Option<ActorRef<unknown>>


setReceiveTimeout(ms): void

Defined in: src/ActorContext.ts:74

Fire a ReceiveTimeout message when no user message has been received in ms. Pass 0 to disable.

number

void


stash(): void

Defined in: src/ActorContext.ts:86

Buffer the message currently being handled. It is reinserted into the mailbox when unstashAll() is called. Throws if called outside a user-message handler or if the stash is full.

void


stop(ref): void

Defined in: src/ActorContext.ts:50

Ask the runtime to stop the given actor. Equivalent to ref.stop().

ActorRef

void


stopSelf(): void

Defined in: src/ActorContext.ts:53

Stop this actor itself.

void


throttle(opts): void

Defined in: src/ActorContext.ts:122

Throttle this actor’s user-message processing to a token-bucket rate (#83). Every dequeue from the user mailbox consumes one token; when the bucket is empty the cell behaves per ThrottleOnExcess. System messages (Terminated, supervision, watchNotify) are NOT throttled — they always run immediately, so timer fires and lifecycle events stay responsive.

Calling throttle again replaces the existing limiter; pass { qps: Infinity } or call cancelThrottle to remove one.

Cluster-aware variants (split a budget across cluster-router routees, etc.) are out of scope here — this is per-actor only.

ThrottleOptions

void


unbecome(): void

Defined in: src/ActorContext.ts:68

Pop the behaviour stack, restoring the previous behaviour.

void


unstashAll(): void

Defined in: src/ActorContext.ts:92

Prepend every stashed message back onto the user mailbox in the order they were stashed. The buffer is empty afterwards.

void


unwatch(ref): ActorRef

Defined in: src/ActorContext.ts:59

Stop watching.

ActorRef

ActorRef


watch(ref): ActorRef

Defined in: src/ActorContext.ts:56

Start death-watching an actor. A Terminated message is sent when it stops.

ActorRef

ActorRef