Class CloudTasksWriterOptions

java.lang.Object
io.github.flink.gcp.connector.cloudtasks.sink.CloudTasksWriterOptions
All Implemented Interfaces:
Serializable

@Public public final class CloudTasksWriterOptions extends Object implements Serializable
Tuning options for the sink's writer: the in-flight cap, the transport channel pool and the two retry budgets.

Set via CloudTasksSinkBuilder.writerOptions(CloudTasksWriterOptions); optional — every knob is defaulted, so defaults() is equivalent to not setting options at all.

There are deliberately no rate knobs. Cloud Tasks paces dispatch on the queue ( maxDispatchesPerSecond, maxConcurrentDispatches, the retry configuration), which is queue configuration applied by whoever creates the queue. What this sink bounds is how many task creations it keeps outstanding, not how fast the tasks execute. The channel pool is not a rate knob either: it sizes how much of the in-flight cap the transport can actually carry concurrently.

Retries are the sink's own because the generated client does not retry CreateTask: its retryable-code set is empty and its total timeout is 20 seconds, while the read-only methods do retry (verified in CloudTasksStubSettings; the dated verification record is ADR-0048). NOT_FOUND has a budget of its own because a queue idle for 30 days takes a few minutes to re-activate and returns NOT_FOUND meanwhile, while a mistyped queue name must not burn the full retry budget on every record before the job fails.

Instances are immutable and serializable.

See Also:
  • Method Details

    • builder

      public static CloudTasksWriterOptions.Builder builder()
      Returns:
      a new builder
    • defaults

      public static CloudTasksWriterOptions defaults()
      Returns the default options: an in-flight cap of 1000, the client's default transport (one gRPC channel), a transient-failure budget of 100 ms doubling to 10 s over 8 attempts, and a NOT_FOUND budget of 500 ms doubling to 2 s over 3 attempts.
      Returns:
      the default options
    • getMaxInFlightTasks

      public int getMaxInFlightTasks()
      Returns the writer's cap on outstanding task creations.
    • getChannelPoolSize

      @Nullable public Integer getChannelPoolSize()
      Returns the configured gRPC channel-pool size, or null when the client's default transport is left alone.
    • getRecoveryInitialBackoff

      public Duration getRecoveryInitialBackoff()
      Returns the first backoff of the transient-failure retry.
    • getRecoveryMaxBackoff

      public Duration getRecoveryMaxBackoff()
      Returns the backoff cap of the transient-failure retry.
    • getRecoveryMaxAttempts

      public int getRecoveryMaxAttempts()
      Returns the maximum attempts of the transient-failure retry.
    • getNotFoundRecoveryInitialBackoff

      public Duration getNotFoundRecoveryInitialBackoff()
      Returns the first backoff of the NOT_FOUND retry.
    • getNotFoundRecoveryMaxBackoff

      public Duration getNotFoundRecoveryMaxBackoff()
      Returns the backoff cap of the NOT_FOUND retry.
    • getNotFoundRecoveryMaxAttempts

      public int getNotFoundRecoveryMaxAttempts()
      Returns the maximum attempts of the NOT_FOUND retry.
    • isPerDestinationMetrics

      public boolean isPerDestinationMetrics()
      Returns whether the writer registers per-queue send counters.
    • toRecoverySchedule

      @Internal public RetrySchedule toRecoverySchedule()
      Returns the schedule retrying UNAVAILABLE, DEADLINE_EXCEEDED and RESOURCE_EXHAUSTED creations.
    • toNotFoundRecoverySchedule

      @Internal public RetrySchedule toNotFoundRecoverySchedule()
      Returns the schedule retrying NOT_FOUND creations. Jittered like the transient schedule: every subtask that hit the same missing queue retries against the same queue once it is created, and the jitter is mean-preserving, so spreading the attempts costs the short budget nothing in expectation.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object