janj

janj

Extending supervisor functionality: updating child restart parameters and publishing events

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?

Popular in Chat/Questions Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
younes-alouani
I’m studying Phoenix Framework but I want to understand basics first. Which book/mooc explains better the Design of Network-based Softwar...
New
logesh
Could someone provide a learning path for functional programming for who came from oops background.? Thanks in advance
New
makeitrein
More Ecto questions! More madness! The context: there’s a list of books that I want to filter with a dropdown… The dropdown: looks some...
New
Chawki
hi,i’m new to programming world i had learned front-end( javascript,react.js) and i wanna learn a back-end programming language i thought...
New
koen_vb
Hi, I was looking for a pointer of how I could most easily start with phoenix regarding deploying it to something like linode or google c...
New
marciol
Hey, I have very restricted resources and time so I’m trying to understand the best way to learn Liveview in terms of cost/time. The Pra...
New

Other popular topics Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42533 114
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement