Class UniqueKillSwitch

java.lang.Object
org.apache.pekko.stream.UniqueKillSwitch
All Implemented Interfaces:
KillSwitch

public final class UniqueKillSwitch extends Object implements KillSwitch
A UniqueKillSwitch is always a result of a materialization (unlike SharedKillSwitch which is constructed before any materialization) and it always controls that graph and operator which yielded the materialized value.

After calling shutdown() the running instance of the Graph of FlowShape that materialized to the UniqueKillSwitch will complete its downstream and cancel its upstream (unless if finished or failed already in which case the command is ignored). Subsequent invocations of completion commands will be ignored.

After calling abort(java.lang.Throwable) the running instance of the Graph of FlowShape that materialized to the UniqueKillSwitch will fail its downstream with the provided exception and cancel its upstream (unless if finished or failed already in which case the command is ignored). Subsequent invocations of completion commands will be ignored.

It is also possible to individually cancel, complete or fail upstream and downstream parts by calling the corresponding methods.

  • Method Details

    • abort

      public void abort(Throwable ex)
      After calling abort(java.lang.Throwable) the running instance of the Graph of FlowShape that materialized to the UniqueKillSwitch will fail its downstream with the provided exception and cancel its upstream (unless if finished or failed already in which case the command is ignored). Subsequent invocations of completion commands will be ignored.
      Specified by:
      abort in interface KillSwitch
    • shutdown

      public void shutdown()
      After calling shutdown() the running instance of the Graph of FlowShape that materialized to the UniqueKillSwitch will complete its downstream and cancel its upstream (unless if finished or failed already in which case the command is ignored). Subsequent invocations of completion commands will be ignored.
      Specified by:
      shutdown in interface KillSwitch
    • toString

      public String toString()
      Overrides:
      toString in class Object