Run 2, 3, or more sessions in separate terminals:
iex --sname socrates --cookie monster -S mix
iex --sname plato --cookie monster -S mix
iex --sname aristotle --cookie monster -S mix
All the nodes will connect to each other automatically (thanks to libcluster
and LocalEpmd
strategy). After that we can "play" and send messages to the processes (with Pidgy.append/1
). We can check all processes' states with Pidgy.all_states/1
:
iex-aristotle> Pidgy.all_states()
[{#PID<22291.236.0>, []}, {#PID<22292.226.0>, []}, {#PID<0.229.0>, []}]
iex-aristotle> Pidgy.append(100_500)
:ok
iex-aristotle> Pidgy.all_states()
[
{#PID<22291.236.0>, [100500]},
{#PID<22292.226.0>, [100500]},
{#PID<0.229.0>, []}
]
In the other terminal sessions we can also run
Pidgy.all_states/1
orPidgy.append/1
.