Class StepOptions.Builder

java.lang.Object
io.superdurable.dex.StepOptions.Builder
Enclosing class:
StepOptions

public static final class StepOptions.Builder extends Object
Builds immutable StepOptions values.
  • Method Details

    • waitForMethodTimeout

      public StepOptions.Builder waitForMethodTimeout(Duration value)
      Sets the maximum duration of one wait-for method attempt.

      An attempt defaults to two hours. This setting applies to every attempt with either Step durability.

      Parameters:
      value - the method timeout, or null for the server default
      Returns:
      this builder
    • executeMethodTimeout

      public StepOptions.Builder executeMethodTimeout(Duration value)
      Sets the maximum duration of one execute method attempt.

      An attempt defaults to two hours. This setting applies to every attempt with either Step durability.

      Parameters:
      value - the method timeout, or null for the server default
      Returns:
      this builder
    • heartbeatTimeout

      public StepOptions.Builder heartbeatTimeout(Duration value)
      Sets the heartbeat timeout for wait-for and execute method attempts.

      Dex sends no automatic heartbeat. Application code must call Context.recordHeartbeat(Object) or write a Stream often enough to make progress. null and Duration.ZERO use the one-minute server default. Explicit values must be whole seconds within the signed int32 range and satisfy the server-configured minimum, which defaults to ten seconds. This setting applies to every attempt with either Step durability. Once cancellation reaches the Java Worker, Dex interrupts the handler thread.

      Parameters:
      value - the heartbeat timeout, or null for one minute
      Returns:
      this builder
    • waitForRetry

      public StepOptions.Builder waitForRetry(RetryPolicy value)
      Sets the retry policy for wait-for method failures.
      Parameters:
      value - the retry policy, or null for the server default
      Returns:
      this builder
    • executeRetry

      public StepOptions.Builder executeRetry(RetryPolicy value)
      Sets the retry policy for execute method failures.
      Parameters:
      value - the retry policy, or null for the server default
      Returns:
      this builder
    • waitForFailure

      public StepOptions.Builder waitForFailure(WaitForFailurePolicy value)
      Sets the action taken after wait-for retries are exhausted.

      This policy does not change durability selection. The method override takes precedence over FlowConfig's default, followed by the synchronous server default.

      Parameters:
      value - the failure policy; the default is WaitForFailurePolicy.FAIL_FLOW
      Returns:
      this builder
    • onExecuteFailureProceedTo

      public <I> StepOptions.Builder onExecuteFailureProceedTo(Class<? extends Step<I>> stepClass)
      Continues to a recovery Step after execute retries are exhausted.

      The recovery Step receives null input. Its input type should therefore accept null, commonly Void.

      This policy does not change durability selection. The method override takes precedence over FlowConfig's default, followed by the synchronous server default.

      Type Parameters:
      I - the recovery Step input type
      Parameters:
      stepClass - the nonnull recovery Step class
      Returns:
      this builder
      Throws:
      NullPointerException - if stepClass is null
    • onExecuteFailureProceedTo

      public <I> StepOptions.Builder onExecuteFailureProceedTo(Class<? extends Step<I>> stepClass, StepOptions options)
      Continues to a recovery Step with per-execution options after execute retries fail.

      The same durability guidance as onExecuteFailureProceedTo(Class) applies. The options parameter configures the recovery Step execution; configure the failing Step's execute durability on the builder receiving this method call.

      Type Parameters:
      I - the recovery Step input type
      Parameters:
      stepClass - the nonnull recovery Step class
      options - recovery execution options, or null for the Step defaults
      Returns:
      this builder
      Throws:
      NullPointerException - if stepClass is null
    • waitForDurability

      public StepOptions.Builder waitForDurability(StepDurability value)
      Overrides durability for this Step's wait-for method result.

      This method-level value takes precedence over FlowConfig's default and the synchronous server default. Failure policy does not alter that ordering. See StepDurability for the asynchronous replay tradeoff.

      Parameters:
      value - the durability mode; the default is StepDurability.DEFAULT
      Returns:
      this builder
    • executeDurability

      public StepOptions.Builder executeDurability(StepDurability value)
      Overrides durability for this Step's execute method result.

      This method-level value takes precedence over FlowConfig's default and the synchronous server default. Failure policy does not alter that ordering. See StepDurability for the asynchronous replay tradeoff.

      Parameters:
      value - the durability mode; the default is StepDurability.DEFAULT
      Returns:
      this builder
    • addWaitForLock

      public StepOptions.Builder addWaitForLock(AttributeLock value)
      Adds an Attribute lock held while the wait-for method runs.
      Parameters:
      value - the lock definition
      Returns:
      this builder
    • addExecuteLock

      public StepOptions.Builder addExecuteLock(AttributeLock value)
      Adds an Attribute lock held while the execute method runs.
      Parameters:
      value - the lock definition
      Returns:
      this builder
    • addWaitForLoadAttributeMap

      public StepOptions.Builder addWaitForLoadAttributeMap(AttributeMap<?> value)
      Loads every current instance of an AttributeMap for WaitFor.
      Parameters:
      value - an AttributeMap registered by the Step's Flow
      Returns:
      this builder
      Throws:
      NullPointerException - during mapping if value is null
    • addWaitForLoadAttributeMapInstance

      public StepOptions.Builder addWaitForLoadAttributeMapInstance(AttributeMap<?> value, String instance)
      Loads one AttributeMap instance for WaitFor.
      Parameters:
      value - an AttributeMap registered by the Step's Flow
      instance - the slash-free instance key
      Returns:
      this builder
    • addWaitForLoadChannel

      public StepOptions.Builder addWaitForLoadChannel(Channel<?> value)
      Loads pending messages from one Channel for WaitFor.
      Parameters:
      value - a Channel registered by the Step's Flow
      Returns:
      this builder
    • addWaitForLoadChannelMap

      public StepOptions.Builder addWaitForLoadChannelMap(ChannelMap<?> value)
      Loads pending messages from every current instance of a ChannelMap for WaitFor.
      Parameters:
      value - a ChannelMap registered by the Step's Flow
      Returns:
      this builder
    • addWaitForLoadChannelMapInstance

      public StepOptions.Builder addWaitForLoadChannelMapInstance(ChannelMap<?> value, String instance)
      Loads pending messages from one ChannelMap instance for WaitFor.
      Parameters:
      value - a ChannelMap registered by the Step's Flow
      instance - the slash-free instance key
      Returns:
      this builder
    • addExecuteLoadAttributeMap

      public StepOptions.Builder addExecuteLoadAttributeMap(AttributeMap<?> value)
      Loads every current instance of an AttributeMap for Execute.
      Parameters:
      value - an AttributeMap registered by the Step's Flow
      Returns:
      this builder
    • addExecuteLoadAttributeMapInstance

      public StepOptions.Builder addExecuteLoadAttributeMapInstance(AttributeMap<?> value, String instance)
      Loads one AttributeMap instance for Execute.
      Parameters:
      value - an AttributeMap registered by the Step's Flow
      instance - the slash-free instance key
      Returns:
      this builder
    • addExecuteLoadChannel

      public StepOptions.Builder addExecuteLoadChannel(Channel<?> value)
      Loads pending messages from one Channel for Execute.
      Parameters:
      value - a Channel registered by the Step's Flow
      Returns:
      this builder
    • addExecuteLoadChannelMap

      public StepOptions.Builder addExecuteLoadChannelMap(ChannelMap<?> value)
      Loads pending messages from every current ChannelMap instance for Execute.
      Parameters:
      value - a ChannelMap registered by the Step's Flow
      Returns:
      this builder
    • addExecuteLoadChannelMapInstance

      public StepOptions.Builder addExecuteLoadChannelMapInstance(ChannelMap<?> value, String instance)
      Loads pending messages from one ChannelMap instance for Execute.
      Parameters:
      value - a ChannelMap registered by the Step's Flow
      instance - the slash-free instance key
      Returns:
      this builder
    • build

      public StepOptions build()
      Builds immutable Step options from the current values.
      Returns:
      the configured Step options