QueueRepository

class QueueRepository(context: Context, logs: RingLog, crypto: CryptoProvider, openHelperFactory: SupportSQLiteOpenHelper.Factory? = null)

Constructors

Link copied to clipboard
constructor(context: Context, logs: RingLog, crypto: CryptoProvider, openHelperFactory: SupportSQLiteOpenHelper.Factory? = null)

Functions

Link copied to clipboard
suspend fun applyRetention(cfg: KioskOpsConfig)

Retention: delete SENT and FAILED events older than the configured window. This supports minimization requirements and prevents unbounded local storage growth.

Link copied to clipboard
suspend fun countActive(): Long
Link copied to clipboard
fun countActiveFlow(): Flow<Long>

Reactive queue depth: emits on every DB change that affects the non-SENT count.

Link copied to clipboard
Link copied to clipboard
suspend fun delete(id: String)
Link copied to clipboard
suspend fun deleteByUserId(userId: String): Int
Link copied to clipboard
suspend fun enqueue(type: String, payloadJson: String, cfg: KioskOpsConfig, stableEventId: String? = null, idempotencyKeyOverride: String? = null, userId: String? = null, dataClassification: String? = null, anomalyScore: Float? = null): EnqueueResult
Link copied to clipboard
suspend fun getAnomalous(threshold: Float): List<QueueEventEntity>
Link copied to clipboard
suspend fun getByUserId(userId: String): List<QueueEventEntity>
Link copied to clipboard
suspend fun markBatchFailureNoAttemptBump(id: String, err: String, nextAttemptAtMs: Long)

Record a batch-level failure for an event without incrementing its attempts counter. See QueueDao.markBatchFailureNoAttemptBump.

Link copied to clipboard
suspend fun markFailed(id: String, err: String, nextAttemptAtMs: Long, permanentFailure: Int, quarantineReason: String? = null)
Link copied to clipboard
suspend fun markSending(id: String)
Link copied to clipboard
suspend fun markSent(id: String)
Link copied to clipboard
suspend fun nextBatch(nowMs: Long, limit: Int = 25): List<QueueEventEntity>
Link copied to clipboard
Link copied to clipboard
suspend fun reconcileStaleSending(staleBeforeEpochMs: Long): Int

Reset SENDING rows older than staleBeforeEpochMs back to PENDING. Called on SDK init so crash-abandoned events don't rot forever. Returns number of rows rescued.