Class PollingOptions
- java.lang.Object
-
- ai.extend.wrapper.utilities.polling.PollingOptions
-
public class PollingOptions extends java.lang.ObjectConfiguration options for polling operations with hybrid polling strategy.The default strategy polls at 1-second intervals for the first 30 seconds, then gradually increases the interval using exponential backoff (1.15x multiplier) up to a maximum of 30 seconds between polls.
Use the builder pattern to create instances with custom values:
// Polls indefinitely with default hybrid strategy PollingOptions options = PollingOptions.builder().build(); // With custom timeout PollingOptions options = PollingOptions.builder() .maxWaitMs(300000) // 5 minutes .build(); // Custom fast polling phase PollingOptions options = PollingOptions.builder() .fastPollDurationMs(60000) // Fast poll for 60 seconds .fastPollIntervalMs(500) // Poll every 500ms during fast phase .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPollingOptions.BuilderBuilder forPollingOptions.
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_BACKOFF_MULTIPLIERDefault backoff multiplier: 1.15 (15% increase each attempt).static intDEFAULT_FAST_POLL_DURATION_MSDefault fast poll duration: 30 seconds (30,000 ms).static intDEFAULT_FAST_POLL_INTERVAL_MSDefault fast poll interval: 1 second (1,000 ms).static intDEFAULT_INITIAL_DELAY_MSDefault initial delay for backoff phase: 1 second (1,000 ms).static doubleDEFAULT_JITTER_FRACTIONDefault jitter fraction: 0.25 (±25% randomization).static intDEFAULT_MAX_DELAY_MSDefault maximum delay between polls: 30 seconds (30,000 ms).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PollingOptions.Builderbuilder()Creates a new builder with default values.static PollingOptionsdefaults()Creates default polling options (polls indefinitely).doublegetBackoffMultiplier()Returns the multiplier for exponential backoff.intgetFastPollDurationMs()Returns the duration of the fast polling phase in milliseconds.intgetFastPollIntervalMs()Returns the interval between polls during the fast polling phase in milliseconds.intgetInitialDelayMs()Returns the initial delay for the backoff phase in milliseconds.doublegetJitterFraction()Returns the jitter fraction for delay randomization.intgetMaxDelayMs()Returns the maximum delay between polls in milliseconds.java.lang.IntegergetMaxWaitMs()Returns the maximum total wait time in milliseconds, or null if polling indefinitely.RequestOptionsgetRequestOptions()Returns the request options to pass to API calls.booleanhasTimeout()Returns whether a timeout is configured.
-
-
-
Field Detail
-
DEFAULT_FAST_POLL_DURATION_MS
public static final int DEFAULT_FAST_POLL_DURATION_MS
Default fast poll duration: 30 seconds (30,000 ms).- See Also:
- Constant Field Values
-
DEFAULT_FAST_POLL_INTERVAL_MS
public static final int DEFAULT_FAST_POLL_INTERVAL_MS
Default fast poll interval: 1 second (1,000 ms).- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_DELAY_MS
public static final int DEFAULT_INITIAL_DELAY_MS
Default initial delay for backoff phase: 1 second (1,000 ms).- See Also:
- Constant Field Values
-
DEFAULT_MAX_DELAY_MS
public static final int DEFAULT_MAX_DELAY_MS
Default maximum delay between polls: 30 seconds (30,000 ms).- See Also:
- Constant Field Values
-
DEFAULT_BACKOFF_MULTIPLIER
public static final double DEFAULT_BACKOFF_MULTIPLIER
Default backoff multiplier: 1.15 (15% increase each attempt).- See Also:
- Constant Field Values
-
DEFAULT_JITTER_FRACTION
public static final double DEFAULT_JITTER_FRACTION
Default jitter fraction: 0.25 (±25% randomization).- See Also:
- Constant Field Values
-
-
Method Detail
-
getMaxWaitMs
public java.lang.Integer getMaxWaitMs()
Returns the maximum total wait time in milliseconds, or null if polling indefinitely.
-
hasTimeout
public boolean hasTimeout()
Returns whether a timeout is configured.
-
getFastPollDurationMs
public int getFastPollDurationMs()
Returns the duration of the fast polling phase in milliseconds.
-
getFastPollIntervalMs
public int getFastPollIntervalMs()
Returns the interval between polls during the fast polling phase in milliseconds.
-
getInitialDelayMs
public int getInitialDelayMs()
Returns the initial delay for the backoff phase in milliseconds.
-
getMaxDelayMs
public int getMaxDelayMs()
Returns the maximum delay between polls in milliseconds.
-
getBackoffMultiplier
public double getBackoffMultiplier()
Returns the multiplier for exponential backoff.
-
getJitterFraction
public double getJitterFraction()
Returns the jitter fraction for delay randomization.
-
getRequestOptions
public RequestOptions getRequestOptions()
Returns the request options to pass to API calls.
-
builder
public static PollingOptions.Builder builder()
Creates a new builder with default values.
-
defaults
public static PollingOptions defaults()
Creates default polling options (polls indefinitely).
-
-