Class Effect$


  • public class Effect$
    extends java.lang.Object
    Factory methods for creating Effect directives - how an event sourced actor reacts on a command.
    • 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
      <Event,​State>
      EffectBuilder<Event,​State>
      none()
      Do not persist anything
      <Event,​State>
      ReplyEffect<Event,​State>
      noReply()
      When EventSourcedBehavior.withEnforcedReplies is used there will be compilation errors if the returned effect isn't a ReplyEffect.
      <Event,​A extends Event,​B extends Event,​State>
      EffectBuilder<Event,​State>
      persist​(A evt1, B evt2, scala.collection.immutable.Seq<Event> events)
      Persist multiple events
      <Event,​State>
      EffectBuilder<Event,​State>
      persist​(Event event)
      Persist a single event
      <Event,​State>
      EffectBuilder<Event,​State>
      persist​(scala.collection.immutable.Seq<Event> events)
      Persist multiple events
      <ReplyMessage,​Event,​State>
      ReplyEffect<Event,​State>
      reply​(ActorRef<ReplyMessage> replyTo, ReplyMessage replyWithMessage)
      Send a reply message to the command.
      <Event,​State>
      ReplyEffect<Event,​State>
      stash()
      Stash the current command.
      <Event,​State>
      EffectBuilder<Event,​State>
      stop()
      Stop this persistent actor Side effects can be chained with thenRun
      <Event,​State>
      EffectBuilder<Event,​State>
      unhandled()
      This command is not handled, but it is not an error that it isn't.
      <Event,​State>
      Effect<Event,​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 <Event,​State> EffectBuilder<Event,​State> persist​(Event event)
        Persist a single event

        Side effects can be chained with thenRun

      • persist

        public <Event,​A extends Event,​B extends Event,​State> EffectBuilder<Event,​State> persist​(A evt1,
                                                                                                                        B evt2,
                                                                                                                        scala.collection.immutable.Seq<Event> events)
        Persist multiple events

        Side effects can be chained with thenRun

      • persist

        public <Event,​State> EffectBuilder<Event,​State> persist​(scala.collection.immutable.Seq<Event> events)
        Persist multiple events

        Side effects can be chained with thenRun

      • none

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

        Side effects can be chained with thenRun

      • unhandled

        public <Event,​State> EffectBuilder<Event,​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 <Event,​State> EffectBuilder<Event,​State> stop()
        Stop this persistent actor Side effects can be chained with thenRun
      • stash

        public <Event,​State> ReplyEffect<Event,​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 EventSourcedBehavior.onPersistFailure.

        Side effects can be chained with thenRun

      • unstashAll

        public <Event,​State> Effect<Event,​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,​Event,​State> ReplyEffect<Event,​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 EventSourcedBehavior is created with EventSourcedBehavior.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 <Event,​State> ReplyEffect<Event,​State> noReply()
        When EventSourcedBehavior.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.