PollingApi

interface PollingApi

Public abstraction layer for consumers. Exposes a small, stable API surface. Internals are delegated to the PollingEngine implementation.

Plain-English entrypoints:

  • startPolling { ... } — start and observe via Flow

  • doPolling { ... } — alias for startPolling, reads more naturally in code

  • run(config) — run synchronously (suspending) and return a terminal outcome

Inheritors

Functions

Link copied to clipboard
abstract fun activePollsCount(): Int

Number of active polling sessions.

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

Cancel a session using the session handle.

abstract suspend fun cancel(id: String)

Cancel a session by ID.

Link copied to clipboard
abstract suspend fun cancelAll()

Cancel all active sessions.

Link copied to clipboard
abstract suspend 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
abstract suspend fun listActiveIds(): List<String>

IDs of active polling sessions.

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

Pause a session by ID.

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

Resume a session by ID.

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

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

Link copied to clipboard
abstract suspend fun shutdown()

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

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

Start a new polling session using the fluent builder DSL.

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

Update backoff/options for a running session by ID.