skunkwerks / swirl

[alpha] IETF PPSP RFC7574 in Erlang/OTP -- an incomplete non-functional partial implementation
http://www.swirl-project.org/
Apache License 2.0
175 stars 13 forks source link

implement channel manager service #22

Closed dch closed 9 years ago

dch commented 9 years ago

api

-spec channel_manager:acquire(ppspp_options:root_hash()) ->
    ppspp_channel:channel().
-spec channel_manager:release(ppspp_channel:channel()) -> ok.
-spec channel_manager:find_swarm_worker(ppspp_options:root_hash()) ->
   swarm_worker:worker_id().
-spec channel_manager:find_swarm_worker(ppspp_channel:channel()) ->
   swarm_worker:worker_id().
-spec channel_manager:get_swarm_options(ppspp_channel:channel()) ->
    ppspp_options:options().
-spec channel_manager:get_swarm_options(ppspp_options:root_hash()) ->
    ppspp_options:options().

-spec swarm_worker:get_swarm_options(ppspp_channel:channel()) ->
    ppspp_options:options().
-spec swarm_worker:get_swarm_options(ppspp_options:root_hash()) ->
    ppspp_options:options().

notes

dch commented 9 years ago

Quick notes on using gproc:

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.