Queue scrobbles offline and flush with WorkManager
When a submit fails for a transient reason (no connection, bad gateway, server error, rate limit) the scrobble is saved to a Room table and a network-constrained WorkManager job sends it later, in batches of 50, oldest first. Plays too old for the server are dropped, and a rejected session or unexpected error leaves the queue untouched. Safe to retry as the server dedupes on (user, played_at, artist, track). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee34963799
commit
fa4eab47b3
15 files changed
+488
-12
No files matched your search
@@ -12,6 +12,9 @@ espressoCore = "3.5.1"
|
||||
okhttp = "4.12.0"
|
||||
serialization = "1.8.1"
|
||||
coroutines = "1.10.2"
|
||||
room = "2.8.4"
|
||||
work = "2.11.2"
|
||||
ksp = "2.3.12"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
@@ -29,6 +32,11 @@ okhttp-mockwebserver = { group = "com.squareup.okhttp3", name = "mockwebserver",
|
||||
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }
|
||||
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
|
||||
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
|
||||
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
||||
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
|
||||
androidx-work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "work" }
|
||||
androidx-work-testing = { group = "androidx.work", name = "work-testing", version.ref = "work" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
@@ -37,3 +45,4 @@ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-co
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
Reference in new issue
Block a user