#Extracting Subjects from children of a static supervisor

1 messages · Page 1 of 1 (latest)

umbral mulch
#

gleam_otp's static supervisor discards the data from ChildSpecifications of its children when they are added, which means that I can't just e.g. use start functions for children that return ChildSpecification(Subject(Message)) and return something like a struct containing the default subjects of the children from the start function of my supervisor.

My understanding, then, is that in order to actually access a Subject for a child, I need to either:

  • pass names down the supervision hierarchy to give to the static children and use named subjects; or
  • register the subjects as a side-effect in the actual actor construction function (i.e. a side-effect in the function called in static_supervisor.add).

In my case, the hierarchy that I'm trying to establish looks something like this:

        ┌────────────────────────┐                    
        │Root Supervisor (static)│                    
        └──┬──────────────────┬──┘                    
           │                  │                       
┌──────────┴──┐         ┌─────┴──────────────────────┐
│Manager Actor│         │Monitor Supervisor (factory)│
└─────────────┘         └─────────────┬──────────────┘
       ▲                              │               
       │                         ┌────┴───┐           
       └─────────────────────────┤Monitors│           
               updates           └────────┘           

with the idea that some external things (e.g. an HTTP server elsewhere in the tree) may communicate with this module through the sending and receipt of messages with the Manager Actor. So in a naïve sense, my goal is mostly to be able to make available a Subject for communicating with the Manager Actor in the calling context that establishes the Root Supervisor. Hopefully that's somewhat clear; I'm very new to all this 😅

dense oxide
#

even if you did get the data returned from starting the child just having the Subject wouldn't be sufficient as if the child was restarted the subject would no longer be useful: in that way you're being pushed into solving a problem you were going to have anyway

umbral mulch
#

That's a really good point

dense oxide
#

you'd either use names or a registry here

umbral mulch
#

Thanks a lot, I'll check it out!