Class Effect$


  • public class Effect$
    extends java.lang.Object
    Factory methods for creating Effect directives - how a DurableStateBehavior reacts on a command.

    API May Change

    • Field Summary

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

      Constructors 
      Constructor Description
      Effect$()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <State> EffectBuilder<State> delete()
      Delete the persisted state.
      <State> EffectBuilder<State> none()
      Do not persist anything
      <State> ReplyEffect<State> noReply()
      When DurableStateBehavior.withEnforcedReplies is used there will be compilation errors if the returned effect isn't a ReplyEffect.
      <State> EffectBuilder<State> persist​(State state)
      Persist new state.
      <ReplyMessage,​State>
      ReplyEffect<State>
      reply​(ActorRef<ReplyMessage> replyTo, ReplyMessage replyWithMessage)
      Send a reply message to the command.
      <State> ReplyEffect<State> stash()
      Stash the current command.
      <State> EffectBuilder<State> stop()
      Stop this persistent actor Side effects can be chained with thenRun
      <State> EffectBuilder<State> unhandled()
      This command is not handled, but it is not an error that it isn't.
      <State> Effect<State> unstashAll()
      Unstash the commands that were stashed with Effect.stash.
      • Methods inherited from class java.lang.Object

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

      • MODULE$

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

      • Effect$

        public Effect$()
    • Method Detail

      • persist

        public <State> EffectBuilder<State> persist​(State state)
        Persist new state.

        Side effects can be chained with thenRun

      • delete

        public <State> EffectBuilder<State> delete()
        Delete the persisted state.

        Side effects can be chained with thenRun

      • none

        public <State> EffectBuilder<State> none()
        Do not persist anything

        Side effects can be chained with thenRun

      • unhandled

        public <State> EffectBuilder<State> unhandled()
        This command is not handled, but it is not an error that it isn't.

        Side effects can be chained with thenRun

      • stop

        public <State> EffectBuilder<State> stop()
        Stop this persistent actor Side effects can be chained with thenRun
      • stash

        public <State> ReplyEffect<State> stash()
        Stash the current command. Can be unstashed later with Effect.unstashAll.

        Note that the stashed commands are kept in an in-memory buffer, so in case of a crash they will not be processed. They will also be discarded if the actor is restarted (or stopped) due to that an exception was thrown from processing a command or side effect after persisting. The stash buffer is preserved for persist failures if a backoff supervisor strategy is defined with DurableStateBehavior.onPersistFailure.

        Side effects can be chained with thenRun

      • unstashAll

        public <State> Effect<State> unstashAll()
        Unstash the commands that were stashed with Effect.stash.

        It's allowed to stash messages while unstashing. Those newly added commands will not be processed by this unstashAll effect and have to be unstashed by another unstashAll.

        See Also:
        EffectBuilder.thenUnstashAll
      • reply

        public <ReplyMessage,​State> ReplyEffect<State> reply​(ActorRef<ReplyMessage> replyTo,
                                                                   ReplyMessage replyWithMessage)
        Send a reply message to the command. The type of the reply message must conform to the type specified by the passed replyTo ActorRef.

        This has the same semantics as cmd.replyTo.tell.

        It is provided as a convenience (reducing boilerplate) and a way to enforce that replies are not forgotten when the DurableStateBehavior is created with DurableStateBehavior.withEnforcedReplies. When withEnforcedReplies is used there will be compilation errors if the returned effect isn't a ReplyEffect. The reply message will be sent also if withEnforcedReplies isn't used, but then the compiler will not help finding mistakes.

      • noReply

        public <State> ReplyEffect<State> noReply()
        When DurableStateBehavior.withEnforcedReplies is used there will be compilation errors if the returned effect isn't a ReplyEffect. This noReply can be used as a conscious decision that a reply shouldn't be sent for a specific command or the reply will be sent later.