AbstractEventSourcedActor
in package
AbstractYes
Class-based OOP alternative to the functional EventSourcedBehavior API.
Users extend this class and override abstract methods to define their domain logic. The actor delegates to PersistenceEngine::create() for recovery and persistence handling.
Immutable via clone — with* methods return new instances.
Tags
Table of Contents
Methods
- __construct() : mixed
- applyEvent() : S
- Apply an event to the state, returning the new state.
- emptyState() : S
- The initial empty state before any events have been applied.
- handleCommand() : Effect
- Handle a command and return an Effect describing what should happen.
- persistenceId() : PersistenceId
- The unique persistence identity for this actor.
- toBehavior() : Behavior
- Build a Behavior by delegating to PersistenceEngine::create().
- toProps() : Props
- Build Props from the behavior, ready for spawning.
- withReplayFilter() : static
- withRetention() : static
- withSnapshotStore() : static
- withSnapshotStrategy() : static
- withWriterId() : static
Methods
__construct()
public
__construct(EventStore $eventStore) : mixed
Parameters
- $eventStore : EventStore
applyEvent()
Apply an event to the state, returning the new state.
public
abstract applyEvent(S $state, E $event) : S
Parameters
- $state : S
- $event : E
Return values
SemptyState()
The initial empty state before any events have been applied.
public
abstract emptyState() : S
Return values
ShandleCommand()
Handle a command and return an Effect describing what should happen.
public
abstract handleCommand(S $state, ActorContext $ctx, object $command) : Effect
Parameters
- $state : S
- $ctx : ActorContext
- $command : object
Return values
EffectpersistenceId()
The unique persistence identity for this actor.
public
abstract persistenceId() : PersistenceId
Return values
PersistenceIdtoBehavior()
Build a Behavior by delegating to PersistenceEngine::create().
public
toBehavior() : Behavior
Return values
BehaviortoProps()
Build Props from the behavior, ready for spawning.
public
toProps() : Props
Return values
PropswithReplayFilter()
public
withReplayFilter(ReplayFilter $filter) : static
Parameters
- $filter : ReplayFilter
Return values
staticwithRetention()
public
withRetention(RetentionPolicy $policy) : static
Parameters
- $policy : RetentionPolicy
Return values
staticwithSnapshotStore()
public
withSnapshotStore(SnapshotStore $store) : static
Parameters
- $store : SnapshotStore
Return values
staticwithSnapshotStrategy()
public
withSnapshotStrategy(SnapshotStrategy $strategy) : static
Parameters
- $strategy : SnapshotStrategy
Return values
staticwithWriterId()
public
withWriterId(Ulid $writerId) : static
Parameters
- $writerId : Ulid