question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow suspending functions in EventPublisherEvent handlers

See original GitHub issue

Would 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
maczikaszcommented, Oct 21, 2019

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

1reaction
RobWincommented, Oct 21, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found