https://kotlinlang.org logo
#arrow
Title
j

Jörg Winter

07/05/2023, 9:36 AM
Hi, there is a reference to a new library(?) "arrow-resilience".. this will be a separate dependency, right ? https://arrow-kt.io/learn/resilience/retry-and-repeat/#repeating-an-action When I use any function from resilience (Schedule.repeat for example), a "suspend" context is required. When the functionality I want to protect by resilience is non-suspend ("eager" is the wording in arrow ?), can I use the resilience API also in an eager context ? Is wrapping the blocking functionality in a "runBlocking" recommended ?
s

simon.vergauwen

07/05/2023, 11:37 AM
Hmm 🤔 The only reason this is
suspend
is so that we can allow
suspend
functions inside
log
,
doUntil
, etc. Schedule doesn't actually use any suspension inside, so if your Schedule is suspension free and your code inside
retry
or
repeat
is suspension free than using
runBlocking
will not actually block IIRC.
We use some things like
currentCoroutineContext()
but that doesn't actually suspend. There is no recommended way, since unrelated changes in the code might break this but there should be no problem with
runBlocking
actually blocking in the case you're describing.
6 Views