DurableStateEngine
in package
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:
- Loads the current state from the DurableStateStore (if available)
- 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
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
Return values
Behavior —The behavior to use when spawning the actor