LeonHartley / Coerce-rs

Actor runtime and distributed systems framework for Rust
711 stars 23 forks source link

Request: Supervision Strategies / Agent Restart Behaviors #29

Open daveman1010221 opened 1 year ago

daveman1010221 commented 1 year ago

It's possible I've missed this, but I haven't been able to figure out how a supervised actor (one that is spawned by another) might be restarted, in the event of a failure case.

LeonHartley commented 1 year ago

Hi @daveman1010221

There are currently only 2 ways actors will be restarted/re-attempted to be started automatically in the event of a failure:

For cases not covered, I think it's difficult to define what is an "actor failure", which is easy with runtimes like Akka/Akka.NET since exceptions exist, and can be caught.

When an actor that was spawned by a parent actor stops, a notification is sent to the supervising actor, for which the handling can be overridden via the on_child_stopped function - inside there you could implement custom logic to re-start any actors that were stopped.

Cheers, Leon