Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add monitoring of actors from peers, without full linking support. #170

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

slawlor
Copy link
Owner

@slawlor slawlor commented Sep 25, 2023

Motivation

linking an actor to another actor, in ractor, 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 monitoring (along with unmonitor and clear_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 underlying Actor::State be as limited in trait implementations as possible (just Send + 'static)

Tests added on new functionality

@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Patch coverage: 94.70% and project coverage change: +0.29% 🎉

Comparison is base (bb33d4f) 78.91% compared to head (8a3ed35) 79.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
+ Coverage   78.91%   79.20%   +0.29%     
==========================================
  Files          49       49              
  Lines        8977     9123     +146     
==========================================
+ Hits         7084     7226     +142     
- Misses       1893     1897       +4     
Files Changed Coverage Δ
ractor/src/pg/mod.rs 72.32% <ø> (ø)
ractor/src/registry/pid_registry.rs 93.65% <ø> (ø)
ractor/src/actor/messages.rs 68.18% <60.00%> (-1.47%) ⬇️
ractor/src/actor/tests/supervisor.rs 92.12% <96.03%> (+0.40%) ⬆️
ractor/src/actor/actor_cell.rs 95.00% <100.00%> (+0.31%) ⬆️
ractor/src/actor/actor_ref.rs 86.11% <100.00%> (ø)
ractor/src/actor/mod.rs 90.22% <100.00%> (+0.09%) ⬆️
ractor/src/actor/supervision.rs 98.43% <100.00%> (+0.65%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@slawlor slawlor force-pushed the double_link_err branch 2 times, most recently from 427d42e to 14aa922 Compare September 25, 2023 12:45
@slawlor slawlor marked this pull request as ready for review September 25, 2023 12:50
@slawlor slawlor merged commit 7382cb2 into main Sep 25, 2023
@slawlor slawlor deleted the double_link_err branch September 25, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant