View Source Solo (solo v0.4.2)
Solo
is the library to turn parts of the existing supervision trees into singletons.
Consider the application having the following children specified somewhere in the supervision tree.
children = [
Foo,
{Bar, [bar_arg]},
{Baz, [baz_arg]},
...
]
and there is a necessity to make Bar
and Baz
processes singletons across the cluster.
Simply wrap the specs in question into Solo.global/2
and you are all set.
children = [
Foo,
Solo.global(SoloBarBaz, [
{Bar, [bar_arg]},
{Baz, [baz_arg]}
],
...
]
Summary
Interface
Helper to make parts of the supervision tree a global distributed singleton.
Shenanigans
Returns the state of the Solo
from this node’s perspective (pids of workers
might be remote.)
Looks the process with the name given as the first parameter up.
Interface
Helper to make parts of the supervision tree a global distributed singleton.
Simply wrap the parts of any supervision tree with a call to Solo.global/2
and you ar eall set.
children = [
Foo,
Solo.global(SoloBarBaz, [
{Bar, [bar_arg]},
{Baz, [baz_arg]}
],
...
]
The name (SoloBarBaz
) above might be used later to check the state of the
running Solo
supervisor with Solo.state/1
, although this is usually not
a demanded feature.
To lookup the named processes turned into Solo
, use Solo.whereis/1
,
passing the respective id (SoloBarBaz
) and the actual name of the process.