What alternatives are available after the removal of the monitor
API?
#307
Replies: 3 comments
-
Hello! Yes, the monitor API was deprecated in 0.11 due to excessive memory allocation use with each instantiated actor. It's possible we could add it back under a feature gate, which would allow people to opt-in to the functionality if necessary. From users, we also had no reported usage of the API, so it was debatable the value it brought in the system which also contributed to the deprecation. If you want, you can pretty trivially add it back by undoing what the removal PR did, and gate the struct fields and associated methods with a feature. I don't think I'll have time to do it immediately, but we did have enough test coverage that was originally removed, so undoing the removal and adding a feature is an easy thing for a new comer to take on if you're willing! Personally, and from production experience, I don't think it's necessary to make it a hard feature of every actor without specifically opting in. From your own examples, I would personally choose direct supervision vs monitoring in actor management. The main reason being, monitoring is only possible post-spawning an actor, meaning you race with the capture functionality on the actor's I do see some value, and possibly clearer patterns, in your examples so I agree there's value in adding the API back, but it's also a tradeoff in functionality performance (unless we maybe store the functionality as a |
Beta Was this translation helpful? Give feedback.
-
For reference, it was dropped specifically in PR #260 |
Beta Was this translation helpful? Give feedback.
-
I had a chance to address this functionality gap and added it back in #317. However due to the memory regression it introduces, for now it's gated behind a feature ( |
Beta Was this translation helpful? Give feedback.
-
@slawlor
The first version I worked with was
ractor-0.9.2
, where themonitor
API was available for monitoring other actors. This API was highly convenient and frequently used. Recently, in my new project usingractor-0.14.2
, I noticed that themonitor
API was no longer present. After checking the Changelog, I discovered that themonitor
API was entirely removed starting fromractor-0.11.0
. This is quite unfortunate.Previously, you described Ractor as "A pure-Rust actor framework inspired by Erlang's
gen_server
, with the speed and performance of Rust!" I enjoy using the actor model in my projects and consider themonitor
API a core feature of the actor model, on par withlink
. Although not always necessary, themonitor
API is a standard feature for the actor model. Without it, the model feels incomplete.Similar breaking changes occurred in
CAF
(C++ Actor Framework) when theclass group
and related APIs were removed. However, CAF users could still usemulticaster<T>
orpublisher<T>
to achieve functionality similar togroup
.Typical use cases for the
monitor
API include:Network Connection Management: A
ConnectActor
manages automatic reconnections of a TCP client to the server. When the connection succeeds, aTcpSessionActor
is dynamically created and monitored using themonitor
API. If the connection is interrupted,ConnectActor
receives anActorTerminated
message, retries the connection, and creates a new session once connected.File Upload Service: In a file upload service, each upload request spawns an
UploadActor
to handle the file data. A "management" actor monitors activeUploadActors
for better session management.IoT Device Management: In IoT systems, devices like cameras or sensors have individual
DeviceActors
for communication. A centralDeviceManagerActor
monitors theseDeviceActors
to handle offline devices or trigger reconnection and alerts.Payment Processing System: For online payments, each transaction spawns a
PaymentSessionActor
to handle communication with payment gateways. APaymentManagerActor
monitors the payment process and handles retries or user notifications in case of failures.In all these scenarios, the core idea is the same: a "manager" actor monitors a "worker" actor, receiving
ActorTerminated
messages upon the latter's exit. This demonstrates the robustness and self-healing capabilities of the actor model.So, is the
monitor
API truly unavailable in versions afterractor-0.11.0
? Or could you consider providing some basic infrastructure that allows users to implement the monitor API themselves?Beta Was this translation helpful? Give feedback.
All reactions