abstract class EventSourcedEntity[Command, Event, State >: Null] extends EventSourcedBehavior[Command, Event, State]
Any Behavior can be used as a sharded entity actor, but the combination of sharding and persistent
actors is very common and therefore this PersistentEntity
class is provided as convenience.
It is a EventSourcedBehavior and is implemented in the same way. It selects the persistenceId
automatically from the EntityTypeKey and entityId
constructor parameters by using
EntityTypeKey.persistenceIdFrom.
- Source
- EventSourcedEntity.scala
- Alphabetic
- By Inheritance
- EventSourcedEntity
- EventSourcedBehavior
- DeferredBehavior
- Behavior
- AnyRef
- Any
- by BehaviorDecorators
- by BehaviorDecorators
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new EventSourcedEntity(entityTypeKey: EntityTypeKey[Command], entityId: String, onPersistFailure: BackoffSupervisorStrategy)
- new EventSourcedEntity(entityTypeKey: EntityTypeKey[Command], entityId: String)
Concrete Value Members
-
def
apply(context: TypedActorContext[Command]): Behavior[Command]
INTERNAL API: DeferredBehavior init
INTERNAL API: DeferredBehavior init
- Definition Classes
- EventSourcedBehavior → DeferredBehavior
- Annotations
- @InternalApi()
- val entityId: String
- val entityTypeKey: EntityTypeKey[Command]
-
def
eventAdapter(): EventAdapter[Event, _]
- Definition Classes
- EventSourcedBehavior
-
final
def
narrow[U <: Command]: Behavior[U]
Narrow the type of this Behavior, which is always a safe operation.
Narrow the type of this Behavior, which is always a safe operation. This method is necessary to implement the contravariant nature of Behavior (which cannot be expressed directly due to type inference problems).
- Definition Classes
- Behavior
-
def
onRecoveryCompleted(state: State): Unit
The
callback
function is called to notify the actor that the recovery process is finished.The
callback
function is called to notify the actor that the recovery process is finished.- Definition Classes
- EventSourcedBehavior
-
def
onRecoveryFailure(failure: Throwable): Unit
The
callback
function is called to notify the actor that the recovery process has failedThe
callback
function is called to notify the actor that the recovery process has failed- Definition Classes
- EventSourcedBehavior
-
def
onSnapshot(meta: SnapshotMetadata, result: Optional[Throwable]): Unit
Override to get notified when a snapshot is finished.
Override to get notified when a snapshot is finished.
- result
None if successful otherwise contains the exception thrown when snapshotting
- Definition Classes
- EventSourcedBehavior
-
final
def
orElse(that: Behavior[Command]): Behavior[Command]
Composes this
Behavior with a fallback
Behaviorwhich is used when this
Behaviordoesn't handle the message or signal, i.e. when
unhandledis returned.
Composes this
Behavior with a fallback
Behaviorwhich is used when this
Behaviordoesn't handle the message or signal, i.e. when
unhandledis returned.
- that
the fallback
Behavior
- Definition Classes
- Behavior
-
val
persistenceId: PersistenceId
- Definition Classes
- EventSourcedBehavior
-
def
shouldSnapshot(state: State, event: Event, sequenceNr: Long): Boolean
Initiates a snapshot if the given function returns true.
Initiates a snapshot if the given function returns true. When persisting multiple events at once the snapshot is triggered after all the events have been persisted.
receives the State, Event and the sequenceNr used for the Event
- returns
true
if snapshot should be saved for the given event
- Definition Classes
- EventSourcedBehavior
- See also
-
def
snapshotEvery(): Long
Override and define that snapshot should be saved every N events.
Override and define that snapshot should be saved every N events.
If this is overridden
shouldSnapshot
is not used.- returns
number of events between snapshots, should be greater than 0
- Definition Classes
- EventSourcedBehavior
- See also
-
def
tagsFor(event: Event): Set[String]
The
tagger
function should give event tags, which will be used in persistence queryThe
tagger
function should give event tags, which will be used in persistence query- Definition Classes
- EventSourcedBehavior
Shadowed Implicit Value Members
-
val
behavior: Behavior[Command]
- Implicit
- This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(eventSourcedEntity: BehaviorDecorators[Command]).behavior
- Definition Classes
- BehaviorDecorators
-
val
behavior: Behavior[Command]
- Implicit
- This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(eventSourcedEntity: BehaviorDecorators[Command]).behavior
- Definition Classes
- BehaviorDecorators
-
def
widen[U](matcher: PartialFunction[U, Command]): Behavior[U]
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy.
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy. Signals are not transformed.
Example:
receive[String] { (ctx, msg) => println(msg); same }.widen[Number] { case b: BigDecimal => s"BigDecimal($b)" case i: BigInteger => s"BigInteger($i)" // all other kinds of Number will be `unhandled` }
Scheduled messages via akka.actor.typed.scaladsl.TimerScheduler can currently not be used together with
widen
, see issue #25318.- Implicit
- This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(eventSourcedEntity: BehaviorDecorators[Command]).widen(matcher)
- Definition Classes
- BehaviorDecorators
-
def
widen[U](matcher: PartialFunction[U, Command]): Behavior[U]
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy.
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy. Signals are not transformed.
Example:
receive[String] { (ctx, msg) => println(msg); same }.widen[Number] { case b: BigDecimal => s"BigDecimal($b)" case i: BigInteger => s"BigInteger($i)" // all other kinds of Number will be `unhandled` }
Scheduled messages via akka.actor.typed.scaladsl.TimerScheduler can currently not be used together with
widen
, see issue #25318.- Implicit
- This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(eventSourcedEntity: BehaviorDecorators[Command]).widen(matcher)
- Definition Classes
- BehaviorDecorators