Polling

Public facade instance for consumers. Delegates to the internal engine.

This is the single entry-point to start, control, and run polling operations.

Examples:

Polling.startPolling { fetch = { /* ... return PollingResult */} isTerminalSuccess = { it == "COMPLETED" } backoff = BackoffPolicies.quick20s }

// Alias that reads more naturally Polling.doPolling { fetch = { /* ... */} isTerminalSuccess = { it == "DONE" } }

Functions

Link copied to clipboard
open override fun activePollsCount(): Int

Number of active polling sessions.

Link copied to clipboard
open suspend override fun cancel(session: PollingSession)

Cancel a session using the session handle.

open suspend override fun cancel(id: String)

Cancel a session by ID.

Link copied to clipboard
open suspend override fun cancelAll()

Cancel all active sessions.

Link copied to clipboard
open suspend override fun <T> compose(vararg configs: PollingConfig<T>): PollingOutcome<T>

Compose multiple polling configs sequentially.

Link copied to clipboard
open fun <T> doPolling(builder: PollingConfigBuilder<T>.() -> Unit): Flow<PollingOutcome<T>>

Alias for startPolling that reads more naturally in codebases. Example: Polling.doPolling { fetch = { ... } }

Link copied to clipboard
open suspend override fun listActiveIds(): List<String>

IDs of active polling sessions.

Link copied to clipboard
open suspend override fun pause(id: String)

Pause a session by ID.

Link copied to clipboard
open suspend override fun resume(id: String)

Resume a session by ID.

Link copied to clipboard
open suspend override fun <T> run(config: PollingConfig<T>): PollingOutcome<T>

One-shot polling that runs to completion synchronously (suspending).

Link copied to clipboard
open suspend override fun shutdown()

Shutdown the SDK's internal engine. After shutdown, new sessions cannot be started.

Link copied to clipboard
open override fun <T> startPolling(builder: PollingConfigBuilder<T>.() -> Unit): Flow<PollingOutcome<T>>

Start a new polling session using the fluent builder DSL.

Link copied to clipboard
open suspend override fun updateBackoff(id: String, newPolicy: BackoffPolicy)

Update backoff/options for a running session by ID.