Class DurableStateBehavior$


  • public class DurableStateBehavior$
    extends java.lang.Object
    API May Change
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static DurableStateBehavior$ MODULE$
      Static reference to the singleton instance of this Scala object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <Command,​State>
      DurableStateBehavior<Command,​State>
      apply​(PersistenceId persistenceId, State emptyState, scala.Function2<State,​Command,​Effect<State>> commandHandler)
      Create a Behavior for a persistent actor with durable storage of its state.
      long lastSequenceNumber​(ActorContext<?> context)
      The last sequence number that was persisted, can only be called from inside the handlers of a DurableStateBehavior
      <Command,​State>
      DurableStateBehavior<Command,​State>
      withEnforcedReplies​(PersistenceId persistenceId, State emptyState, scala.Function2<State,​Command,​ReplyEffect<State>> commandHandler)
      Create a Behavior for a persistent actor that is enforcing that replies to commands are not forgotten.
      <Command,​State>
      DurableStateBehavior<Command,​State>
      withEnforcedRepliesMutableState​(PersistenceId persistenceId, scala.Function0<State> emptyStateFactory, scala.Function2<State,​Command,​ReplyEffect<State>> commandHandler)
      Create a Behavior with mutable state for a persistent actor that is enforcing that replies to commands are not forgotten.
      <Command,​State>
      DurableStateBehavior<Command,​State>
      withMutableState​(PersistenceId persistenceId, scala.Function0<State> emptyStateFactory, scala.Function2<State,​Command,​Effect<State>> commandHandler)
      Create a Behavior with mutable state for a persistent actor with durable storage of its state.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULE$

        public static final DurableStateBehavior$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • DurableStateBehavior$

        public DurableStateBehavior$()
    • Method Detail

      • apply

        public <Command,​State> DurableStateBehavior<Command,​State> apply​(PersistenceId persistenceId,
                                                                                     State emptyState,
                                                                                     scala.Function2<State,​Command,​Effect<State>> commandHandler)
        Create a Behavior for a persistent actor with durable storage of its state.

        This can be used when the state is immutable, but if the state is mutable, it is important to use the withMutableState that takes emptyStateFactory: () => State parameter.

        Parameters:
        persistenceId - stable unique identifier for the DurableStateBehavior
        emptyState - the intial state for the entity before any state has been stored
        commandHandler - map commands to effects e.g. persisting state, replying to commands
      • withMutableState

        public <Command,​State> DurableStateBehavior<Command,​State> withMutableState​(PersistenceId persistenceId,
                                                                                                scala.Function0<State> emptyStateFactory,
                                                                                                scala.Function2<State,​Command,​Effect<State>> commandHandler)
        Create a Behavior with mutable state for a persistent actor with durable storage of its state.

        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.

        Parameters:
        persistenceId - stable unique identifier for the DurableStateBehavior
        emptyStateFactory - factory function of the intial state for the entity before any state has been stored
        commandHandler - map commands to effects e.g. persisting state, replying to commands
      • withEnforcedReplies

        public <Command,​State> DurableStateBehavior<Command,​State> withEnforcedReplies​(PersistenceId persistenceId,
                                                                                                   State emptyState,
                                                                                                   scala.Function2<State,​Command,​ReplyEffect<State>> commandHandler)
        Create a Behavior 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.

        This can be used when the state is immutable, but if the state is mutable, it is important to use the withEnforcedRepliesMutableState that takes emptyStateFactory: () => State parameter.

      • withEnforcedRepliesMutableState

        public <Command,​State> DurableStateBehavior<Command,​State> withEnforcedRepliesMutableState​(PersistenceId persistenceId,
                                                                                                               scala.Function0<State> emptyStateFactory,
                                                                                                               scala.Function2<State,​Command,​ReplyEffect<State>> commandHandler)
        Create a Behavior with 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.

      • lastSequenceNumber

        public long lastSequenceNumber​(ActorContext<?> context)
        The last sequence number that was persisted, can only be called from inside the handlers of a DurableStateBehavior