Class Wait

java.lang.Object
io.superdurable.dex.Wait

public final class Wait extends Object
Describes when Dex may invoke a Step's execute method.

Return a Wait from Step.waitFor(Context, I). The value is declarative and immutable: Dex persists and evaluates its Timer, Channel, and SubFlow conditions without blocking the worker thread that produced it. Use until(Condition) for a single condition, allOf(Condition...) or anyOf(Condition...) for a flat group, and anyCombinationOf(ConditionCombination...) for alternatives containing multiple conditions.

public Wait waitFor(Context context, Order input) {
    return Wait.anyOf(
            paymentReceived.forOne(),
            Timer.byDuration(Duration.ofHours(1)));
}
  • Method Details

    • skipImmediately

      public static Wait skipImmediately()
      Skips condition evaluation and makes the Step immediately eligible to execute.
      Returns:
      an immediate wait definition
    • until

      public static Wait until(Condition condition)
      Waits for one condition to be satisfied.

      The Condition does not need a condition ID.

      Parameters:
      condition - the single Timer, Channel, or SubFlow condition
      Returns:
      a wait equivalent to allOf(condition)
    • allOf

      public static Wait allOf(Condition... conditions)
      Waits until every supplied condition is satisfied.

      This combinator does not require condition IDs. Every Condition in anyCombinationOf(ConditionCombination...) does require one.

      Parameters:
      conditions - the conditions that must all be satisfied
      Returns:
      an all-of wait definition
    • anyOf

      public static Wait anyOf(Condition... conditions)
      Waits until any supplied condition is satisfied.

      Conditions do not need condition IDs. Read Channel results from the Channel definition and inspect Timer outcomes through Context.

      Among ready conditions, Dex selects the first in canonical order: Timers, Channels, then SubFlows, preserving argument order within each kind. An unready condition does not block a later ready condition. To wait for strict priority, return only the higher-priority condition.

      Channel consumption is not greedy across alternatives. Dex consumes messages only from the selected Channel condition; other ready Channel conditions consume nothing.

      Parameters:
      conditions - the alternative conditions
      Returns:
      an any-of wait definition
    • anyCombinationOf

      public static Wait anyCombinationOf(ConditionCombination... combinations)
      Waits until every condition in any one supplied combination is satisfied.

      Channel consumption is not greedy across combinations. Dex consumes messages only from Channel conditions in the selected combination. Conditions belonging only to other ready combinations consume nothing.

      Every Condition must have a non-empty user-provided ID. Reusing the same Condition object across combinations is supported; distinct Conditions must not share an ID.

      Parameters:
      combinations - alternative all-of condition groups
      Returns:
      an any-combination wait definition
      Throws:
      InvalidStepResultException - when a Condition ID is missing, empty, or duplicated