Supports Kotlin Multiplatform.
Agentic AI features are being sorted out.
Agentic AI features are being sorted out.
io.turbodsl will not make your application faster, but will make your development easier and most importantly, write asynchronous code in a natural way using DSL expressions.
Overall performance differences between low-level-coroutine approach vs. io.turbodsl is negligible.
io.turbodsl allows you to write clean and predictable code, easier to review and maintain.
Latest version: v1.2.6
🌟Includes support for Kotlin Multiplatform
build.gradle.kts
dependencies {
implementation("io.turbodsl:io-turbodsl-core:1.2.6")
:
}
It already includes these dependencies:
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0")
api("org.jetbrains.kotlinx:kotlinx-datetime:0.8.0")
api("org.jetbrains.kotlin:kotlin-reflect:2.4.21") // jvm
api("org.jetbrains:annotations:26.1.0") // jvm
}
Writing asynchronous code using io.turbodsl is simple:
// Restrict all execution to 10 seconds.
TurboScope.execute(timeout = 10_000L) {
// Execute 3 jobs in parallel, and retry up to 10 times.
// Return empty-string after last retry failure.
// Restrict each retry execution to 2 seconds.
retry(retries = 10, timeout = 2_000L, default = Default.EmptyString) {
async(
// Cancel pending jobs on first failure
asyncMode = AsyncScope.AsyncMode.CancelFirst,
throwOnFailure = true,
job1 = asyncJob<String>(timeout = 500L) { "job1" },
job2 = asyncJob<String>(delay = 100L) { "job2" },
job3 = asyncJob<String>(timeout = 1_000L) { "job3" },
) { _, r1, r2, r3 ->
// Since `throwOnFailure` is true, then this block is executed only if all jobs are successful.
"${r1.success()} ${r2.success()} ${r3.success()}"
}
}.let { data ->
// Retry 3 more times, delaying 0.5, 1, 2 seconds respectively
retry<String, String>(input = data, retries = 3, retryDelay = 500, retryDelayFactor = 2.0) {
// Maps each character in parallel (0 means trigger as many coroutines as items in collection)
input.toList().asyncMap(maxJobs = 0) {
when (it) {
'j' -> 1
'o' -> 2
'b' -> 3
' ' -> 0
else -> it
}
}.joinToString(separator = "-")
}
}
}.let {
// Prints out: 1-2-3-1-0-1-2-3-2-0-1-2-3-3
println("Result: $it")
}