Skip to content

//sorisdk/com.iplateia.sorisdk/PendingRequestManager

PendingRequestManager

class PendingRequestManager(apiClient: SORIApiClient, config: SORIConfig)

Manager for handling pending API requests when network connectivity is unavailable.

This class provides a robust mechanism for queuing failed network requests and automatically retrying them when network connectivity is restored. It maintains an in-memory queue of pending requests with automatic expiration based on configured time limits.

Key Features

  • Automatic Queuing: Failed requests due to network issues are automatically queued
  • Time-based Expiration: Requests older than the configured timeout are automatically discarded
  • Concurrent Processing: Thread-safe queue management using ConcurrentLinkedQueue
  • Configurable Behavior: Respects SORIConfig settings for enabling/disabling delayed sending

Usage Example

kotlin
val manager = PendingRequestManager(apiClient, config)

// Add a failed request to the queue
manager.addPendingRequest(materialId)

// Process all pending requests when network is restored
manager.processPendingRequests(scope) { materialId, campaign ->
    // Handle the result
}

Since

4.3.2

See also

SORIConfig
NetworkUtils
PendingActivityRequest

Constructors

PendingRequestManager[androidJvm]
constructor(apiClient: SORIApiClient, config: SORIConfig)
Creates a new PendingRequestManager with the specified API client and configuration

Types

NameSummary
Companion[androidJvm]
object Companion

Functions

NameSummary
addPendingRequest[androidJvm]
fun addPendingRequest(materialId: String)
Adds a failed request to the pending queue for later retry.
clearPendingRequests[androidJvm]
fun clearPendingRequests()
Clears all pending requests from the queue.
getPendingRequestCount[androidJvm]
fun getPendingRequestCount(): Int
Returns the current number of pending requests in the queue.
processPendingRequests[androidJvm]
fun processPendingRequests(scope: CoroutineScope, onResult: (String, SORICampaign?) -> Unit)
Processes all pending requests in the queue.