I am trying to run a list of tasks under a Dynamic Supervisor. Imagine that it is a URL downloader. I need to know if they are still running, and maybe talk to them to change their configuration in-flight.
In order to talk to them, each task is registered as {Download, "www.example.com"}
in a global registry. Now, the application runs a dynamic number of sub-applications, so that there is
- {DynamicSupervisor “customer-a”}
- {Downloader “www.example.com”}
- {Downloader “www.esempio.it”}
- {DynamicSupervisor “customer-b”}
- {Downloader “www.exemplum.de”}
So I basically want to know which Download modules are running under {DynamicSupervisor "customer-a"}
- so I call it and get a list of children like:
[{:undefined, #PID<0.14119.0>, :worker, [Downloader]},
{:undefined, #PID<0.14123.0>, :worker, [Downloader]}]
The issue is that only the module is reported back, so I cannot know which one it is - I can get the PID, get all the pids out of Registry, and keep the ones that match both, so I can look up the same information. But this seems quite a mouthful.
Is there a way to change the name of the module in the output, or tag it somehow? The first field is supposed to be the :id and it would be perfect, but in DynamicSupervisor, as per the docs (why?) it is always :Undefined.