-
public final class FlushWorker
-
-
Constructor Summary
Constructors Constructor Description FlushWorker(Context context, SuspendFunction4<String, String, ByteArray, Boolean, FlushAttemptResult> networkExecutor)
-
Method Summary
Modifier and Type Method Description final BooleanisStarted()Debug/test introspection (TEST_STATE). final Unitstart()Start listening and attempt an immediate flush on init. final Unitstop()Stop the periodic flush timer. final BooleanhasCachedRequests()Check if there are any cached requests remaining final BooleanisProcessingCache()Check if cache processing is currently in progress final UnitregisterCompletionCallback(SuspendFunction0<Unit> callback)Register a callback to be notified when all cached requests are processed final UnitcacheRequest(CachedRequest req)Append a failed request to the cache file as a single JSON line. final UnitclearCache()Delete all cached requests immediately. final UnitsetPendingRequestsChecker(Function0<Boolean> checker)Set the callback to check for pending network requests final BooleanhasPendingNetworkRequests()Check if there are pending network requests final UnitapplyConfig(Long flushIntervalSeconds, Integer batchSize)-
-
Constructor Detail
-
FlushWorker
FlushWorker(Context context, SuspendFunction4<String, String, ByteArray, Boolean, FlushAttemptResult> networkExecutor)
-
-
Method Detail
-
start
@RequiresPermission(value = android.permission.ACCESS_NETWORK_STATE) final Unit start()
Start listening and attempt an immediate flush on init.
-
hasCachedRequests
final Boolean hasCachedRequests()
Check if there are any cached requests remaining
-
isProcessingCache
final Boolean isProcessingCache()
Check if cache processing is currently in progress
-
registerCompletionCallback
final Unit registerCompletionCallback(SuspendFunction0<Unit> callback)
Register a callback to be notified when all cached requests are processed
-
cacheRequest
final Unit cacheRequest(CachedRequest req)
Append a failed request to the cache file as a single JSON line.
-
clearCache
final Unit clearCache()
Delete all cached requests immediately.
-
setPendingRequestsChecker
final Unit setPendingRequestsChecker(Function0<Boolean> checker)
Set the callback to check for pending network requests
-
hasPendingNetworkRequests
final Boolean hasPendingNetworkRequests()
Check if there are pending network requests
-
applyConfig
final Unit applyConfig(Long flushIntervalSeconds, Integer batchSize)
-
-
-
-