ActorContext
Defined in: src/ActorContext.ts:15
Runtime API given to every Actor. Access through this.context inside
an Actor subclass.
Type Parameters
Section titled “Type Parameters”TMsg = unknown
Properties
Section titled “Properties”children
Section titled “children”
readonlychildren: readonlyActorRef<unknown>[]
Defined in: src/ActorContext.ts:32
Snapshot of direct children.
readonlylog:Logger
Defined in: src/ActorContext.ts:35
Logger bound to this actor’s path.
parent
Section titled “parent”Defined in: src/ActorContext.ts:29
Parent actor, or None for the root guardian.
readonlypath:ActorPath
Defined in: src/ActorContext.ts:20
The ActorPath of this actor.
readonlyself:ActorRef<TMsg>
Defined in: src/ActorContext.ts:17
A reference to this actor.
sender
Section titled “sender”Defined in: src/ActorContext.ts:23
The sender of the message currently being processed, or None.
stashSize
Section titled “stashSize”
readonlystashSize:number
Defined in: src/ActorContext.ts:95
Number of currently-stashed messages.
system
Section titled “system”
readonlysystem:ActorSystem
Defined in: src/ActorContext.ts:26
The enclosing ActorSystem.
timers
Section titled “timers”
readonlytimers: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.
Methods
Section titled “Methods”actorOf()
Section titled “actorOf()”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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Props<T>
string
Returns
Section titled “Returns”ActorRef<T>
actorSelection()
Section titled “actorSelection()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”become()
Section titled “become()”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().
Parameters
Section titled “Parameters”behavior
Section titled “behavior”Receive<TMsg>
discardOld?
Section titled “discardOld?”boolean
Returns
Section titled “Returns”void
cancelReceiveTimeout()
Section titled “cancelReceiveTimeout()”cancelReceiveTimeout():
void
Defined in: src/ActorContext.ts:77
Disable the receive timeout.
Returns
Section titled “Returns”void
cancelThrottle()
Section titled “cancelThrottle()”cancelThrottle():
void
Defined in: src/ActorContext.ts:125
Remove any active throttle, restoring unlimited dequeue rate.
Returns
Section titled “Returns”void
child()
Section titled “child()”Defined in: src/ActorContext.ts:41
Look up a direct child by name. None if no such child exists.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”setReceiveTimeout()
Section titled “setReceiveTimeout()”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.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
stash()
Section titled “stash()”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.
Returns
Section titled “Returns”void
stop()
Section titled “stop()”stop(
ref):void
Defined in: src/ActorContext.ts:50
Ask the runtime to stop the given actor. Equivalent to ref.stop().
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
stopSelf()
Section titled “stopSelf()”stopSelf():
void
Defined in: src/ActorContext.ts:53
Stop this actor itself.
Returns
Section titled “Returns”void
throttle()
Section titled “throttle()”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.
Parameters
Section titled “Parameters”ThrottleOptions
Returns
Section titled “Returns”void
unbecome()
Section titled “unbecome()”unbecome():
void
Defined in: src/ActorContext.ts:68
Pop the behaviour stack, restoring the previous behaviour.
Returns
Section titled “Returns”void
unstashAll()
Section titled “unstashAll()”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.
Returns
Section titled “Returns”void
unwatch()
Section titled “unwatch()”unwatch(
ref):ActorRef
Defined in: src/ActorContext.ts:59
Stop watching.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”watch()
Section titled “watch()”watch(
ref):ActorRef
Defined in: src/ActorContext.ts:56
Start death-watching an actor. A Terminated message is sent when it stops.