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.
Popular in Libraries
Hi everyone,
We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix!
You can read this blog post or the docs for more info...
New
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps:
bureaucrat - which contains a bunch ...
New
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
New
It is a well-know topic within the Elixir community: “To mock or not to mock? :)”
Every alchemist probably has his / her own opinion con...
New
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention.
Assuming you have...
New
Yes, yet another parser combinator library!
Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
New
Hi there,
for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM.
...
New
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
Other popular topics
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
can someone please explain to me how Enum.reduce works with maps
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New







