abstract class EventSourcedBehavior[Command, Event, State >: Null] extends DeferredBehavior[Command]
- Annotations
- @ApiMayChange()
- Source
- EventSourcedBehavior.scala
- Alphabetic
- By Inheritance
- 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 EventSourcedBehavior(persistenceId: PersistenceId, onPersistFailure: BackoffSupervisorStrategy)
- new EventSourcedBehavior(persistenceId: PersistenceId)
Concrete Value Members
-
def
apply(context: TypedActorContext[Command]): Behavior[Command]
INTERNAL API: DeferredBehavior init
INTERNAL API: DeferredBehavior init
- Definition Classes
- EventSourcedBehavior → DeferredBehavior
- Annotations
- @InternalApi()
- def eventAdapter(): EventAdapter[Event, _]
-
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. -
def
onRecoveryFailure(failure: Throwable): Unit
The
callback
function is called to notify the actor that the recovery process has failed -
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
-
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
-
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
-
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
-
def
tagsFor(event: Event): Set[String]
The
tagger
function should give event tags, which will be used in persistence query
Shadowed Implicit Value Members
-
val
behavior: Behavior[Command]
- Implicit
- This member is added by an implicit conversion from EventSourcedBehavior[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:(eventSourcedBehavior: BehaviorDecorators[Command]).behavior
- Definition Classes
- BehaviorDecorators
-
val
behavior: Behavior[Command]
- Implicit
- This member is added by an implicit conversion from EventSourcedBehavior[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:(eventSourcedBehavior: 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 EventSourcedBehavior[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:(eventSourcedBehavior: 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 EventSourcedBehavior[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:(eventSourcedBehavior: BehaviorDecorators[Command]).widen(matcher)
- Definition Classes
- BehaviorDecorators