Nexus API Reference

DurableStateEngine
in package

FinalYes

Core engine that wraps user command handlers into a Behavior with automatic recovery and state persistence.

Unlike PersistenceEngine (event sourcing), DurableStateEngine persists the CURRENT state directly. No events, no replay, no snapshots.

On actor start (setup phase), the engine:

  1. Loads the current state from the DurableStateStore (if available)
  2. Returns a stateful Behavior for command processing

On each message, the engine delegates to the user's commandHandler, interprets the returned DurableEffect, and handles persistence + side effects.

Tags
psalm-api

Table of Contents

Methods

create()  : Behavior
Create a Behavior that wraps durable state persistence around a user-defined command handler.

Methods

create()

Create a Behavior that wraps durable state persistence around a user-defined command handler.

public static create(PersistenceId $persistenceId, S $emptyState, callable(S, ActorContext, object): DurableEffect $commandHandler, DurableStateStore $stateStore[, Ulid $writerId = new Ulid() ]) : Behavior
Parameters
$persistenceId : PersistenceId

Unique identity for this persistent entity

$emptyState : S

Initial empty state before any persisted state

$commandHandler : callable(S, ActorContext, object): DurableEffect

Processes commands, returns DurableEffect

$stateStore : DurableStateStore

Store for persisting and loading state

$writerId : Ulid = new Ulid()

Writer identity stamped on persisted state

Tags
template

S of object

Return values
Behavior

The behavior to use when spawning the actor


        
On this page

Search results