Supervision
A Supervisors
responsibility is to manage actors failure policies.
ZIO
provides us a comprehensive and composable set of Schedules
that can be used to define complex supervising policy.
There are three supervision scenarios available. Let's look at short examples. First do the imports:
import zio.actors._
import zio.{ Supervisor => _, _ }
import java.util.concurrent.TimeUnit
To provide no supervision use none
. Remember that this provide no error recovery for actor:
Supervisor.none
Retrying is provided via retry
with specified Schedule
like recurs
:
Supervisor.retry(Schedule.recurs(10))
The general method also requires effect that will be executed on Schedule
end:
Supervisor.retryOrElse[Any, Long](Schedule.recurs(10), (e, a) => Console.printLine("nothing can be done").orDie)