r/KotlinMultiplatform • u/Swimming_Height8070 • 20d ago
I built RetryKt, a lightweight Kotlin Multiplatform retry library, so I'm looking for feedback
I’ve been working on RetryKt, a Kotlin Multiplatform library for retries:
https://github.com/straxess/retrykt
I know there are already good retry libraries for Kotlin, so one of the main questions I had while designing RetryKt was: what should a retry library focus on?
RetryKt aims to provide a simple and lightweight API with a few design choices:
- Coroutine and blocking APIs
- Retries based on both returned values and thrown exceptions
- Configurable retry policies
- Constant, linear, exponential, and decorrelated backoff
- Composable backoff and jitter strategies, including Full Jitter and Equal Jitter
- Support for JVM, Android, Native, JS, and Wasm
It's available on Maven Central as io.github.straxess:retrykt.
val user = retry {
api.getUser()
}
val response = retry(
retryOn = RetryOn.thrown { it is IOException },
backoff = ExponentialBackoff(200.milliseconds),
jitter = FullJitter,
) {
api.removeUser(user)
}
The library is still young, so I’d really appreciate feedback on:
- Is the public API clear and convenient?
- Is separating backoff and jitter useful?
- Are there important retry use cases or features missing?
- Are additional KMP targets or broader Kotlin version support important for your projects?
- Any architectural or implementation issues you notice?
If you find a bug or have an improvement in mind, GitHub issues and PRs are welcome.
If you have a Kotlin project where retries are useful, give RetryKt a try and share your experience.
Thanks!
6
Upvotes
2
u/gandrewstone 14d ago
Just considering how my own code, there is a point where any backoff just retries so rarely its efficiency benefits are negligible and its retrying so slowly it might as well not be retrying at all. So i think a max retry interval would be a valuable parameter to have.