object EventSourcedBehavior
- Alphabetic
- By Inheritance
- EventSourcedBehavior
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- type CommandHandler[Command, Event, State] = (State, Command) => Effect[Event, State]
Type alias for the command handler function that defines how to act on commands.
Type alias for the command handler function that defines how to act on commands.
The type alias is not used in API signatures because it's easier to see (in IDE) what is needed when full function type is used. When defining the handler as a separate function value it can be useful to use the alias for shorter type signature.
- type EventHandler[State, Event] = (State, Event) => State
Type alias for the event handler function for updating the state based on events having been persisted.
Type alias for the event handler function for updating the state based on events having been persisted.
The type alias is not used in API signatures because it's easier to see (in IDE) what is needed when full function type is used. When defining the handler as a separate function value it can be useful to use the alias for shorter type signature.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply[Command, Event, State](persistenceId: PersistenceId, emptyState: State, commandHandler: (State, Command) => Effect[Event, State], eventHandler: (State, Event) => State): EventSourcedBehavior[Command, Event, State]
Create a
Behaviorfor a persistent actor.Create a
Behaviorfor a persistent actor.This can be used when the state is immutable, but if the state is mutable, it is important to use the
withMutableStatethat takesemptyStateFactory: () => Stateparameter.- persistenceId
stable unique identifier for the event sourced behavior
- emptyState
the intial state for the entity before any events have been processed
- commandHandler
map commands to effects e.g. persisting events, replying to commands
- eventHandler
compute the new state given the current state when an event has been persisted
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def currentMetadata[M](context: ActorContext[_])(implicit arg0: ClassTag[M]): Option[M]
The metadata of the given type that was persisted with an event, if any.
The metadata of the given type that was persisted with an event, if any. Can only be called from inside the event handler or
RecoveryCompletedof anEventSourcedBehavior. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def lastSequenceNumber(context: ActorContext[_]): Long
The last sequence number that was persisted, can only be called from inside the handlers of an
EventSourcedBehavior - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withEnforcedReplies[Command, Event, State](persistenceId: PersistenceId, emptyState: State, commandHandler: (State, Command) => ReplyEffect[Event, State], eventHandler: (State, Event) => State): EventSourcedBehavior[Command, Event, State]
Create a
Behaviorfor a persistent actor that is enforcing that replies to commands are not forgotten.Create a
Behaviorfor a persistent actor that is enforcing that replies to commands are not forgotten. Then there will be compilation errors if the returned effect isn't a ReplyEffect, which can be created with Effect.reply, Effect.noReply, EffectBuilder.thenReply, or EffectBuilder.thenNoReply.This can be used when the state is immutable, but if the state is mutable, it is important to use the
withEnforcedRepliesMutableStatethat takesemptyStateFactory: () => Stateparameter. - def withEnforcedRepliesMutableState[Command, Event, State](persistenceId: PersistenceId, emptyStateFactory: () => State, commandHandler: (State, Command) => ReplyEffect[Event, State], eventHandler: (State, Event) => State): EventSourcedBehavior[Command, Event, State]
Create a
Behaviorwith mutable state for a persistent actor that is enforcing that replies to commands are not forgotten.Create a
Behaviorwith mutable state for a persistent actor that is enforcing that replies to commands are not forgotten. Then there will be compilation errors if the returned effect isn't a ReplyEffect, which can be created with Effect.reply, Effect.noReply, EffectBuilder.thenReply, or EffectBuilder.thenNoReply.When the state is mutable, it is important to use this variant to make sure that the state instance is recreated in case of failure restarts.
- def withMutableState[Command, Event, State](persistenceId: PersistenceId, emptyStateFactory: () => State, commandHandler: (State, Command) => Effect[Event, State], eventHandler: (State, Event) => State): EventSourcedBehavior[Command, Event, State]
Create a
Behaviorwith mutable state for a persistent actor.Create a
Behaviorwith mutable state for a persistent actor.When the state is mutable, it is important to use this variant to make sure that the state instance is recreated in case of failure restarts.
- persistenceId
stable unique identifier for the event sourced behavior
- emptyStateFactory
factory function of the intial state for the entity before any events have been processed
- commandHandler
map commands to effects e.g. persisting events, replying to commands
- eventHandler
compute the new state given the current state when an event has been persisted
- object CommandHandler
The
CommandHandlerdefines how to act on commands.The
CommandHandlerdefines how to act on commands. ACommandHandleris a function:(State, Command) => Effect[Event, State]The CommandHandler#command is useful for simple commands that don't need the state and context.