Allow suspending functions in EventPublisherEvent handlers
See original GitHub issueWould be nice to be able to do something lie this
fun main() {
runBlocking {
val retry = Retry.of(
"test-retry", custom<Any>()
.maxAttempts(4)
.retryExceptions(SomeException::class.java)
.waitDuration(Duration.ofMillis(1000))
.build()
)
retry.eventPublisher.onRetry { println("Retry happened $it"); cleanupBeforeRetry() }
val i2 = retry.executeSuspendFunction { doSomething() }
print(i2)
}
}
suspend fun cleanupBeforeRetry() {
delay(10)
println("Cleanup ")
}
var i = 0
suspend fun doSomething(): Any {
println("Trying")
delay(100)
if (i < 4) {
throw SomeException("asdf")
}
return i
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
21.2.2 Suspending an Event Handler
The rights to suspend event handlers depend on the Event Blackout permission. If this right is not granted to your role, it is...
Read more >How to suspend events when setting a property of a WinForms ...
The class below allows you to effectively suppress all of the events, that are maintained in the EventHandlerList, for a control. The class...
Read more >Side-effects in Compose - Android Developers
LaunchedEffect: run suspend functions in the scope of a composable. To call suspend functions safely from inside a composable, use the LaunchedEffect ...
Read more >Suspending event scheduling in Shiny - Stack Overflow
The idea is to keep track of suspended inputs whose values should not change. Using an event hook, we can then check if...
Read more >Events and Event Handlers in Niagara Effects for Unreal Engine
In many cases, you will want several emitters in one system to interact with each other. In Niagara, this is done using Events...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure syntactically not a problem, semantically I am not familiar enough with the code base, to decide whether it will work properly 😃 but I will give it a try
The core of Resilience4j doesn’t use Kotlin. I can’t change the internal event processor. But could you add extension functions? Like here? -> https://github.com/resilience4j/resilience4j/blob/master/resilience4j-kotlin/src/main/kotlin/io/github/resilience4j/kotlin/circuitbreaker/CircuitBreaker.kt