Closed dch closed 9 years ago
Quick notes on using gproc:
{gproc, ".*", {git, "git://github.com/uwiger/gproc.git", master}},
to rebar.config
and run make deps
to bring it up to dateerl -sname fu -pa deps/gproc/ebin
and another with erl -remsh fu@continuity -sname wu
so we have 2 different processes to play with.In shell fu@:
Eshell V6.2 (abort with ^G)
(fu@continuity)1> application:start(gproc).
ok
(fu@continuity)2> Hash = "c89800bfc82ed01ed6e3bfd5408c51274491f7d4", Key = {n,l, Hash}, Options = {some_options}.
{some_options}
(fu@continuity)3> gproc:reg(Key, Options).
true
(fu@continuity)4> %% peek into gproc's store
(fu@continuity)4> gproc:select([{'_', [], ['$$']}]).
[[{n,l,"c89800bfc82ed01ed6e3bfd5408c51274491f7d4"},
<0.43.0>,
{some_options}]]
(fu@continuity)5>
and on the other node:
Eshell V6.2 (abort with ^G)
(fu@continuity)1> Hash = "c89800bfc82ed01ed6e3bfd5408c51274491f7d4", Key = {n,l, Hash}, Options = {some_options}.
{some_options}
(fu@continuity)2> %% lookup the process that registered this hash.
(fu@continuity)2> gproc:lookup_local_name(Hash).
<0.43.0>
(fu@continuity)3> %% grab the key that was registered by this process
(fu@continuity)3> gproc:lookup_value(Key).
{some_options}
(fu@continuity)4>
Obviously one could also send the process a message to retrieve its state as an explicit message, but given that the options of a peer won't ever change this is a reasonable compromise, as it makes updating the existing peer code very easy.
api
spec
notes