Class PullWorkerOptions.Builder

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

public static final class PullWorkerOptions.Builder extends Object
Builds immutable outbound polling options.

Obtain a builder from PullWorkerOptions.newBuilder(). Zero values use the defaults documented by each setter. The enclosing type shows a complete Worker example.

  • Method Details

    • maxConcurrentTasks

      public PullWorkerOptions.Builder maxConcurrentTasks(int value)
      Sets the number of long-lived execution-slot streams for Step and RPC tasks.

      This also sizes the Worker's handler pool. Worker start fails when this exceeds the Server's per-Worker limit, matching.maxConcurrentTasksCap. Every received task executes without a capacity rejection.

      Parameters:
      value - a nonnegative count; zero uses the available CPU count
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if value is negative
    • reservedRpcTasks

      public PullWorkerOptions.Builder reservedRpcTasks(Integer value)
      Reserves streams that accept only RPC tasks to protect RPC latency from long-running Steps.

      Unset reserves one slot when the resolved task limit is at least two, otherwise zero. Set zero to opt out. With one slot and no explicit reserve, Worker start logs a warning about RPC starvation. The remaining streams accept Steps and RPCs. The Server routes Steps only to those streams, and the Worker never declines a Step for capacity.

      PullWorkerOptions pull = PullWorkerOptions.newBuilder()
              .maxConcurrentTasks(8).reservedRpcTasks(2).build();
      
      Parameters:
      value - nonnegative reserved capacity below the resolved limit; null selects the default
      Returns:
      this builder
      Throws:
      IllegalArgumentException - from build if value is negative or reaches the task limit
    • idleStreamsPerQueue

      @Deprecated public PullWorkerOptions.Builder idleStreamsPerQueue(int value)
      Deprecated.
      execution slots determine the stream count
      Retains the legacy idle-stream option for source compatibility.

      This value has no effect. Each execution slot has exactly one long-lived stream.

      Parameters:
      value - a nonnegative legacy count
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if value is negative
    • appWorkerID

      public PullWorkerOptions.Builder appWorkerID(String value)
      Sets the process identity used for sticky task routing.

      The ID has 1-63 ASCII letters, digits, periods, underscores, or hyphens. It must differ from every registered Flow type. Empty selects a hostname-derived random ID.

      Parameters:
      value - the Worker ID, or empty to generate one
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if value is null or malformed
    • stopDrainTimeout

      public PullWorkerOptions.Builder stopDrainTimeout(Duration value)
      Sets how long Stop waits for active pull tasks before canceling them.

      A canceled handler must return before Stop completes. A stream whose final output the Server has not yet confirmed gets a five-second flush grace after the timeout. The Server confirms it by ending the stream or by assigning the stream's next task.

      Parameters:
      value - a nonnegative duration; zero uses 30 seconds
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if value is null or negative
    • stopOnPermanentStreamRejection

      public PullWorkerOptions.Builder stopOnPermanentStreamRejection(boolean value)
      Stops the Worker on a permanent rejection leaving a required slot kind without a registered stream.

      Defaults to false, which retries indefinitely. When enabled, the first such rejection before or after readiness drains within stopDrainTimeout, then makes Worker.start throw PullRegistrationError. Other registered streams of that slot kind prevent this shutdown. See the enclosing type for a complete options example.

      Parameters:
      value - whether to stop on an uncovered permanent stream rejection
      Returns:
      this builder
    • build

      public PullWorkerOptions build()
      Builds pull options for a Worker.
      Returns:
      immutable pull options