Emil Kantis
08/15/2024, 7:47 AMEmil Kantis
08/15/2024, 7:49 AMprivate val connectRetryPolicy = Schedule
.spaced<Either<Throwable, Unit>>(retryDelay)
.and(Schedule.recurs(maxAttempts))
.doUntil { input, _ -> input.isRight() }
which repeats until we get an Either.Right
. Then I just use .repeat(primaryAction)
to attempt until success.. But I'm not sure how to add the failure action 🙂Emil Kantis
08/15/2024, 7:59 AMval policy = Schedule.identity<Either<Throwable, Unit>>
.zipLeft(Schedule.spaced(retryDelay))
.zipLeft(Schedule.recurs(maxAttempts))
.doUntil { _, output -> output.isRight() }
policy.repeat(primaryAction)
.fold(
ifLeft = { failureAction() }
ifRight = { <http://log.info|log.info>("Success") }
)