All my actors inherit from BaseActor
and can create children actor with registerActor()
abstract class BaseActor() : AbstractLoggingActor() {
protected fun registerActor(childProps: Props, name: String): ActorRef {
val child = context.child(name)
val supervisorProps = BackoffSupervisor.props(
BackoffOpts.onFailure(
childProps,
name,
java.time.Duration.ofSeconds(1),
java.time.Duration.ofSeconds(30),
0.2 // adds 20% "noise" to vary the intervals slightly
).withAutoReset(FiniteDuration(20, TimeUnit.SECONDS))
)
return if (child.isEmpty) {
context.actorOf(supervisorProps, "supervisor_$name").also { addChildRoutee(it) }
} else {
child.get()
}
}
}
When an actor /user/dad
create 2 children actors using registerActor()
however 2 supervisors are created
/user/dad/supervisor_foo/foo
/user/dad/supervisor_bar/bar
How can I reuse the same supervisor to supervise both foo
and bar
?
/user/dad/supervisor/foo
/user/dad/supervisor/bar