In Arrow 1.2.4, why is the construction of CircuitBreaker a suspendable function? What strategy can I use to create a shared CircuitBreaker to be used across multiple API method calls?
s
simon.vergauwen
06/30/2025, 7:16 AM
Hey Kev,
Honsetly, switch to 2.x.x 😅 There it's not suspend. It was suspend because in "pure FP libraries" you can argue that creating an
AtomicReference
is a side-effect and thus needs to be wrapped in
IO
(or
suspend
).
It didn't make any sense in Kotlin (nor in Arrow-kt), it was a bad decision and we reverted it in 2.x.x.
Besides the history rant, you can safely wrap in
runBlocking
and just extract it because it never suspend during construction. I think you can safely do this for KMP since it doesn't actually suspend.