The schedule I'm trying to make would have to:
So what I have is (2.) and (3.):
val repeatUntilTimeLimitReached =
ZSchedule
.fixed(config.pollingConfig.pollInterval)
.untilOutput(pollingTimeLimitReached)
val untilTermination = Schedule.doUntil[RebootState](_.terminatesPolling)
val schedule = repeatUntilTimeLimitReached *> untilTermination
I tried ZSchedule.delayed()
, but it seems to add delay to subsequent schedules too.
So is there any way to add intial delay to ZSchedule
?
After having a small discussion with community it seems that expected behaviour is not achievable with Schedule
(ZIO version: 1.0.0-RC15), since it is used to repeat after the first execution.
I've ended up using ZIO.sleep()
and schedule
I made in the original post:
val schedule = repeatUntilTimeLimitReached *> untilTermination
for {
_ <- ZIO.sleep(initialDelay)
state <- doStuff().repeat(schedule)
} yield state