How would I go about having a `CoroutineScope` tha...
# coroutines
k
How would I go about having a
CoroutineScope
that automatically restarts jobs that have failed? Maybe with exponential backoff?
supervisorScope
doesn't quite get me there, but is a good starting point
z
I don’t think a
CoroutineScope
can perform that kind of funtionality.
Job
isn’t restartable.
k
Hm. I'm trying to think how I would differentiate which job has failed and react accordingly
my use case....
using
CoroutineWorker
as part of workmanager, I want to start several
Flows
that listen from different TCP connections for data/events. If one of those TCP connections loses connection, I'd like to be able to reconnect with exponential backoff.
differentiating which flow has failed is an interesting problem
o
is there some reason you can't have
Flow
do the retry? that's what it's designed for
☝️ 2
k
🤦‍♂️ thank you lol
u
There's also an example of a plain coroutine retry from roman elizarov: https://stackoverflow.com/a/46890009 @there's also a retry example for coroutines form
As noted in the comment, you can also inline it