Class StartFlowOptions.Builder

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

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

    • timeout

      public StartFlowOptions.Builder timeout(Duration value)
      Sets Dex's durable soft timeout for the Flow execution.
      Parameters:
      value - a nonnegative whole-second timeout, or null to disable it
      Returns:
      this builder
    • timeoutPolicy

      public StartFlowOptions.Builder timeoutPolicy(FlowTimeoutPolicy value)
      Sets the action taken when the positive Flow timeout expires.

      The default invokes an overridden Flow.handleTimeout(Context); otherwise it fails the Flow. HANDLER is rejected before start when the target Flow has no override.

      Parameters:
      value - the non-null timeout policy
      Returns:
      this builder
      Throws:
      NullPointerException - if value is null
    • timeoutHandlerOptions

      public StartFlowOptions.Builder timeoutHandlerOptions(FlowTimeoutHandlerOptions value)
      Configures timeout-handler execution and selective state loading.

      This option requires a positive timeout and a policy resolving to HANDLER.

      Parameters:
      value - the handler options, or null for server defaults
      Returns:
      this builder
    • startDelay

      public StartFlowOptions.Builder startDelay(Duration value)
      Delays creation of the first Step execution.
      Parameters:
      value - a nonnegative whole-second delay, or null for no explicit delay
      Returns:
      this builder
    • idReusePolicy

      public StartFlowOptions.Builder idReusePolicy(IdReusePolicy value)
      Sets how an existing Flow ID may be reused.
      Parameters:
      value - the reuse policy; the default is IdReusePolicy.DEFAULT
      Returns:
      this builder
    • retryPolicy

      public StartFlowOptions.Builder retryPolicy(RetryPolicy value)
      Sets retry behavior for abnormal Flow completion.
      Parameters:
      value - the Flow retry policy, or null for no explicit policy
      Returns:
      this builder
    • addAttribute

      public <T> StartFlowOptions.Builder addAttribute(Attribute<T> attribute, T value)
      Adds an initial Attribute value atomically with Flow start.
      Type Parameters:
      T - the Attribute value type
      Parameters:
      attribute - the nonnull registered Attribute
      value - the typed initial value
      Returns:
      this builder
      Throws:
      NullPointerException - if attribute is null
    • addAttribute

      public <T> StartFlowOptions.Builder addAttribute(AttributeMap<T> attributeMap, String instance, T value)
      Adds an initial Attribute-map value atomically with Flow start.
      Type Parameters:
      T - the Attribute value type
      Parameters:
      attributeMap - the nonnull registered Attribute map
      instance - the map instance. Slash is prohibited because it is a reserved character
      value - the typed initial value
      Returns:
      this builder
      Throws:
      NullPointerException - if attributeMap is null
      IllegalArgumentException - if instance is null, blank, or contains /
    • configOverride

      public StartFlowOptions.Builder configOverride(FlowConfig value)
      Overrides Flow configuration for the new execution.
      Parameters:
      value - the per-execution configuration, or null for defaults
      Returns:
      this builder
    • ignoreAlreadyStarted

      public StartFlowOptions.Builder ignoreAlreadyStarted(boolean value)
      Controls whether an already-started response is accepted.

      When enabled, a start rejected because the Flow ID already exists returns the existing run ID only when requestId(String) matches the request ID that started that run. A different or SDK-generated request ID still throws FlowAlreadyStartedException. See StartFlowOptions for an example that sets both options.

      Parameters:
      value - true to ignore the already-started error
      Returns:
      this builder
    • requestId

      public StartFlowOptions.Builder requestId(String value)
      Sets an idempotency key for this start request.

      A retried start returns the existing run only when ignoreAlreadyStarted(boolean) is true and this request ID matches the request that started that run. Without that option, the retry throws FlowAlreadyStartedException even when the first attempt created the Flow. The match applies only when the ID reuse policy rejects the start. A policy that permits another run starts a new run instead. Dex compares only request IDs, not input or other options, so never reuse a request ID for a different logical start. See StartFlowOptions for an example that sets both options.

      Parameters:
      value - the stable request ID, or null to generate a UUID
      Returns:
      this builder
    • build

      public StartFlowOptions build()
      Builds immutable start options from the current values.
      Returns:
      the configured start options