janj

janj

While working with Supervisors, I keep running into two pieces of functionality that are not supported: updating the restart parameters of child processes and subscribing to supervision events. I’m probably missing constraints that need to be met by supervisors, possibly performance, reliability or simplicity related. Could someone shed some light on the design considerations of supervisors so I can see what the impact would be of adding this functionality?
Below, I’ll illustrate where I think the additional functionality would be useful.

Updating child restart parameters
The state of some processes will be updated by users of the system, and losing that changed state could mean the system as a whole does not function correctly. In stead of keeping a copy of the state in another process (as proposed by Dave Thomas in Programming Elixir) and having the child process recover the state of its predecessor, you could update the parameters stored in the supervisor that are used to start the replacement process.

In practice, this would mean adding a function to the supervisor that directly updates the children field of the supervisor struct. You could limit this to only allow children to update their own restart parameters. By adding this functionality, the newly started child would start with the correct state, without having to rely on an external service to recover state from. Are there any drawbacks to this approach?

Subscribing to supervision events
When processes are dependent on each other, we can monitor them to be informed of their untimely demise. This, however, only tells you the process is gone, not which process replaced it (if any). Supervisors have this knowledge, and could inform other processes what happened. This would be especially useful when a lot of other processes rely on that process being around. :syn (a distributed process registry) supports something that is similar, but only reports on process crashes, as it won’t know either which process replaced the crashed one. Have others attempted to publish these events in their supervisors, or is there something wrong with this approach that I’m not seeing?

Where Next? Top

Trending in Chat/Questions Top

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews