Example Bitwalker Swarm app for DFW Elixir Hack Night 2019.04.16
This demo runs a chat server. The chat worker is a global process running on a single node in the cluster, but can be called by any of the other nodes.
Swarm is configured using the Gossip strategy, so all nodes on the same network should automatically connect. Other strategies are available here.
Run each command in a separate shell:
iex --sname n1 --cookie testing -S mix
iex --sname n2 --cookie testing -S mix
In both shells, join the server as a different name:
iex> SwarmChat.join "yourname"
Send messages back and forth.
iex> SwarmChat.msg "this is a message"
When you are done, leave the server:
iex> SwarmChat.leave
SwarmChat.whereis
gives current pid of the workerSwarmChat.state
returns worker's state
- Fix the memory leak in
SwarmChat.Worker
where dead pids are not cleaned up. - Handle state recovery if the node with the worker crashes. Currently the worker's state is reset.
- Put the worker under a supervision tree (difficult with Swarm)