Add monitoring of actors from peers, without full linking support. #170
+211
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
link
ing an actor to another actor, inractor
, invokes the parent-child relationship and makes the parent the supervisor of the child. This means if the parent dies, before the child can process a supervision event (in say a doubly-linked scenario), the child will be terminated as part of the parent's exit flow (and not just terminated, but killed halting any async work in any flow).This is non-ideal for looser ownership scenarios.
This PR introduces the notion of
monitor
ing (along withunmonitor
andclear_monitors
) which allows a non-parent relationship to supervision. This means an actor can monitor another actor without being in the direct lifecycle path yet still receive supervision events.NOTE: In order to not require the state to implement
Clone
, we instead add a "slimmed out" supervision event for monitors, such that they (a) won't receive the actor's state upon a termination event, if available at all, and (b) won't receive the actual exception with potential extra information, rather a serialized string version. This helps require that the underlyingActor::State
be as limited in trait implementations as possible (justSend + 'static
)Tests added on new functionality