Supervising Postgrex.Notifications process?


I have a use case involving a reactive application that reacts to postgres events using NOTIFY. I found this example on how to set it up using postgrex, but I found it weird that it was starting the Postgrex.Notifications process as a child within the Posts.PgListener process (the last code example).

What would be the advantages to do this as opposed to having the Supervisor start and own the Postgrex.Notifications process?

Also, I was facing some challenges supervising it on the top level because the current implementation doesn’t seem to support the name binding. In situations like these, is it more preferable to update the implementation to support name binding, or is there a way to extract the pid out of the supervisor (so that other processes can talk to it)?


1 Like