BackoffSupervisor
Defined in: src/pattern/BackoffSupervisor.ts:182
Base class for user actors. Subclasses must override onReceive.
Lifecycle hooks (preStart, postStop, preRestart, postRestart) have sensible
defaults but can be overridden.
Actors are single-threaded by construction: the runtime guarantees that onReceive is never invoked concurrently for the same actor. If onReceive returns a Promise, the runtime awaits it before starting the next message.
Extends
Section titled “Extends”Actor<unknown>
Type Parameters
Section titled “Type Parameters”T
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BackoffSupervisor<
T>(opts):BackoffSupervisor<T>
Defined in: src/pattern/BackoffSupervisor.ts:232
Parameters
Section titled “Parameters”Returns
Section titled “Returns”BackoffSupervisor<T>
Overrides
Section titled “Overrides”Methods
Section titled “Methods”onReceive()
Section titled “onReceive()”onReceive(
message):Promise<void>
Defined in: src/pattern/BackoffSupervisor.ts:291
Main message handler. Receives each envelope dequeued from the mailbox. A thrown error (sync or async) is caught by the supervisor.
Parameters
Section titled “Parameters”message
Section titled “message”unknown
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”postRestart()
Section titled “postRestart()”postRestart(
_reason):void|Promise<void>
Defined in: src/Actor.ts:55
Called on the fresh instance after a restart. Default: call preStart().
Parameters
Section titled “Parameters”_reason
Section titled “_reason”Error
Returns
Section titled “Returns”void | Promise<void>
Inherited from
Section titled “Inherited from”postStop()
Section titled “postStop()”postStop():
void
Defined in: src/pattern/BackoffSupervisor.ts:335
Called after the actor has been terminated. Children are already stopped.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”preRestart()
Section titled “preRestart()”preRestart(
_reason,_message?):void|Promise<void>
Defined in: src/Actor.ts:50
Called before a restart, on the instance about to be thrown away. The default stops children and then calls postStop().
Parameters
Section titled “Parameters”_reason
Section titled “_reason”Error
_message?
Section titled “_message?”unknown
Returns
Section titled “Returns”void | Promise<void>
Inherited from
Section titled “Inherited from”preStart()
Section titled “preStart()”preStart():
void
Defined in: src/pattern/BackoffSupervisor.ts:287
Called after construction and before the first message is processed.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”supervisorStrategy()
Section titled “supervisorStrategy()”supervisorStrategy():
SupervisorStrategy
Defined in: src/pattern/BackoffSupervisor.ts:280
The supervisor’s own strategy applied to its child. The
decider always returns Directive.Stop (so the cell’s restart
loop doesn’t fight ours), but BEFORE returning it sets
lastTerminationWasFailure — that’s the only place we can
tell “the child crashed” apart from “the child stopped itself
cleanly”. handleTerminated reads the flag, applies the
triggerOn policy (#68), then resets it.
Users should not override this; configure the supervisor’s parent instead if you want a different policy for the supervisor itself.
Returns
Section titled “Returns”Overrides
Section titled “Overrides”props()
Section titled “props()”
staticprops<T>(opts):Props<unknown>
Defined in: src/pattern/BackoffSupervisor.ts:189
Build a Props that spawns a BackoffSupervisor configured with
the given options. Apply withSupervisorStrategy if you want to
change how the supervisor itself is supervised (the child is
always run under stoppingStrategy regardless of this).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Props<unknown>