mudasobwa
Creator of Cure
DistributedSupervisor as a lightweight drop-in replacement for DynamicSupervisor
Since OTP 25.1 we have a process groups monitoring so I finally made an implementation of distributed Registry leveraging :pg and an [almost] drop-in distributed replacement for local DynamicSupervisor.
❯ iex --sname n1 -S mix
iex(n1@am-victus)1> DistributedSupervisor.start_link name: DS, listeners: DistributedSupervisor.Test.Listener, cache_children?: true, monitor_nodes: true
{:ok, #PID<0.254.0>}
iex(n1@am-victus)2> Node.connect :"n2@am-victus"
true
iex(n1@am-victus)3> DistributedSupervisor.start_child DS, {DistributedSupervisor.Test.GenServer, name: Foo1}
{:ok, #PID<24436.263.0>, Foo1}
iex(n1@am-victus)4> DistributedSupervisor.start_child DS, {DistributedSupervisor.Test.GenServer, name: Foo2}
{:ok, #PID<24436.264.0>, Foo2}
iex(n1@am-victus)5> DistributedSupervisor.start_child DS, {DistributedSupervisor.Test.GenServer, name: Foo3}
{:ok, #PID<0.265.0>, Foo3}
iex(n1@am-victus)6> DistributedSupervisor.children DS
%{
Foo1 => #PID<24436.263.0>,
Foo2 => #PID<24436.264.0>,
Foo3 => #PID<0.265.0>,
}
iex(n1@am-victus)7> DistributedSupervisor.whereis DS, Foo1
#PID<24436.263.0>
iex(n1@am-victus)8> DistributedSupervisor.via_name DS, Foo1
{:via, DistributedSupervisor.Registry, {DS, Foo1}}
iex(n1@am-victus)9> GenServer.whereis v()
#PID<24436.263.0>
It supports listener(s) to be attached to each DistributedSupervisor “instance,” identified by a name, to be informed about processes going up/down and nodes going up/down.
Enjoy.
Trending in Announcing
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
New
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Following on from my CLDR lbraries I started work on Unicode transforms. But like everything related to CLDR there is a lot of yak-shavin...
New
Hello
Published a new library - ProcessHub!
ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Squid Mesh is an open source workflow automation runtime for Elixir applications.
It is aimed at Phoenix and OTP apps that want to defin...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









