Class Effect$


  • public class Effect$
    extends java.lang.Object
    Factory methods for creating Effect directives - how a persistent 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>
      Effect<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>
      Effect<Event,​State>
      persist​(A evt1, B evt2, scala.collection.Seq<Event> events)
      Persist multiple events
      <Event,​State>
      Effect<Event,​State>
      persist​(Event event)
      Persist a single event
      <Event,​State>
      Effect<Event,​State>
      persist​(scala.collection.immutable.Seq<Event> events)
      Persist multiple events
      <ReplyMessage,​Event,​State>
      ReplyEffect<Event,​State>
      reply​(ExpectingReply<ReplyMessage> cmd, ReplyMessage replyWithMessage)
      Send a reply message to the command, which implements ExpectingReply.
      <Event,​State>
      ReplyEffect<Event,​State>
      stash()
      Stash the current command.
      <Event,​State>
      Effect<Event,​State>
      stop()
      Stop this persistent actor Side effects can be chained with andThen
      <Event,​State>
      Effect<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> Effect<Event,​State> persist​(Event event)
        Persist a single event

        Side effects can be chained with andThen

        Parameters:
        event - (undocumented)
        Returns:
        (undocumented)
      • persist

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

        Side effects can be chained with andThen

        Parameters:
        evt1 - (undocumented)
        evt2 - (undocumented)
        events - (undocumented)
        Returns:
        (undocumented)
      • persist

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

        Side effects can be chained with andThen

        Parameters:
        events - (undocumented)
        Returns:
        (undocumented)
      • none

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

        Side effects can be chained with andThen

        Returns:
        (undocumented)
      • unhandled

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

        Side effects can be chained with andThen

        Returns:
        (undocumented)
      • stop

        public <Event,​State> Effect<Event,​State> stop()
        Stop this persistent actor Side effects can be chained with andThen
        Returns:
        (undocumented)
      • 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 andThen

        Returns:
        (undocumented)
      • 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.

        Side effects can be chained with andThen, but note that the side effect is run immediately and not after processing all unstashed commands.

        Returns:
        (undocumented)
        See Also:
        Effect.thenUnstashAll
      • reply

        public <ReplyMessage,​Event,​State> ReplyEffect<Event,​State> reply​(ExpectingReply<ReplyMessage> cmd,
                                                                                           ReplyMessage replyWithMessage)
        Send a reply message to the command, which implements ExpectingReply. The type of the reply message must conform to the type specified in ExpectingReply.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.

        Parameters:
        cmd - (undocumented)
        replyWithMessage - (undocumented)
        Returns:
        (undocumented)
      • 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.
        Returns:
        (undocumented)