Interface Creators.Act

  • All Superinterfaces:
    Actor
    All Known Subinterfaces:
    Creators.ActWithStash
    Enclosing interface:
    Creators

    public static interface Creators.Act
    extends Actor
    This trait provides a DSL for writing the inner workings of an actor, e.g. for quickly trying things out in the REPL. It makes the following keywords available:

    - become mapped to context.become(_, discardOld = true)

    - becomeStacked mapped to context.become(_, discardOld = false)

    - unbecome mapped to context.unbecome

    - setup for implementing preStart()

    - whenFailing for implementing preRestart()

    - whenRestarted for implementing postRestart()

    - teardown for implementing postStop

    Using the life-cycle keywords multiple times results in replacing the content of the respective hook.

    • Method Detail

      • become

        void become​(scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> r)
        Replace the behavior at the top of the behavior stack for this actor. The stack is cleared upon restart. Use unbecome() to pop an element off this stack or becomeStacked() to push a new element on top of it.
        Parameters:
        r - (undocumented)
      • becomeStacked

        void becomeStacked​(scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> r)
        Add the given behavior on top of the behavior stack for this actor. This stack is cleared upon restart. Use unbecome() to pop an element off this stack.
        Parameters:
        r - (undocumented)
      • postRestart

        void postRestart​(java.lang.Throwable cause)
        Description copied from interface: Actor
        User overridable callback: By default it calls preStart().
        Specified by:
        postRestart in interface Actor
        Parameters:
        cause - the Throwable that caused the restart to happen

        Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
      • postRestartFun_$eq

        void postRestartFun_$eq​(scala.Function1<java.lang.Throwable,​scala.runtime.BoxedUnit> x$1)
      • postStop

        void postStop()
        Description copied from interface: Actor
        User overridable callback.

        Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.
        Specified by:
        postStop in interface Actor
      • postStopFun_$eq

        void postStopFun_$eq​(scala.Function0<scala.runtime.BoxedUnit> x$1)
      • preRestart

        void preRestart​(java.lang.Throwable cause,
                        scala.Option<java.lang.Object> msg)
        Description copied from interface: Actor
        Scala API: User overridable callback: '''By default it disposes of all children and then calls postStop().'''
        Specified by:
        preRestart in interface Actor
        Parameters:
        cause - the Throwable that caused the restart to happen
        msg - optionally the current message the actor processed when failing, if applicable

        Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated.
      • preRestartFun_$eq

        void preRestartFun_$eq​(scala.Function2<java.lang.Throwable,​scala.Option<java.lang.Object>,​scala.runtime.BoxedUnit> x$1)
      • preStart

        void preStart()
        Description copied from interface: Actor
        User overridable callback.

        Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation.
        Specified by:
        preStart in interface Actor
      • preStartFun_$eq

        void preStartFun_$eq​(scala.Function0<scala.runtime.BoxedUnit> x$1)
      • receive

        scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receive()
        Default behavior of the actor is empty, use become to change this.
        Specified by:
        receive in interface Actor
        Returns:
        (undocumented)
      • super$postRestart

        void super$postRestart​(java.lang.Throwable reason)
      • super$postStop

        void super$postStop()
      • super$preRestart

        void super$preRestart​(java.lang.Throwable reason,
                              scala.Option<java.lang.Object> message)
      • super$preStart

        void super$preStart()
        Replace the postStop action with the supplied thunk. Default action is to call super.postStop.
      • superviseWith

        void superviseWith​(SupervisorStrategy s)
        Set the supervisor strategy of this actor, i.e. how it supervises its children.
        Parameters:
        s - (undocumented)
      • supervisorStrategy

        SupervisorStrategy supervisorStrategy()
        Description copied from interface: Actor
        User overridable definition the strategy to use for supervising child actors.
        Specified by:
        supervisorStrategy in interface Actor
        Returns:
        (undocumented)
      • unbecome

        void unbecome()
        Pop the active behavior from the behavior stack of this actor. This stack is cleared upon restart.
      • whenFailing

        void whenFailing​(scala.Function2<java.lang.Throwable,​scala.Option<java.lang.Object>,​scala.runtime.BoxedUnit> body)
        Replace the preRestart action with the supplied function. Default action is to call super.preRestart(), which will kill all children and invoke postStop().
        Parameters:
        body - (undocumented)
      • whenRestarted

        void whenRestarted​(scala.Function1<java.lang.Throwable,​scala.runtime.BoxedUnit> body)
        Replace the postRestart action with the supplied function. Default action is to call super.postRestart which will call preStart().
        Parameters:
        body - (undocumented)
      • whenStarting

        void whenStarting​(scala.Function0<scala.runtime.BoxedUnit> body)
        Replace the preStart action with the supplied thunk. Default action is to call super.preStart()
        Parameters:
        body - (undocumented)
      • whenStopping

        void whenStopping​(scala.Function0<scala.runtime.BoxedUnit> body)
        Replace the postStop action with the supplied thunk. Default action is to call super.postStop.
        Parameters:
        body - (undocumented)