Skip to content

Commit

Permalink
handle {via, Module, Name} tuple when receiving a message
Browse files Browse the repository at this point in the history
Like OTP gen_servers this changes brings support of the via syntax
allowing partisan to find a process registered through an alternative
process registry.
  • Loading branch information
benoitc committed Apr 18, 2019
1 parent 2c90b33 commit 5e669f5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/partisan_util.erl
Expand Up @@ -230,7 +230,7 @@ maybe_initiate_parallel_connections(Connections0, Channel, Node, ListenAddr, Par

term_to_iolist(Term) ->
[131, term_to_iolist_(Term)].

term_to_iolist_([]) ->
106;
term_to_iolist_({}) ->
Expand Down Expand Up @@ -306,6 +306,9 @@ process_forward(ServerRef, Message) ->
{global, Name} ->
Pid = global:whereis_name(Name),
Pid ! Message;
{via, Module, Name} ->
Pid = Module:whereis_name(Name),
Pid ! Message;
_ ->
ServerRef ! Message,
case partisan_config:get(tracing, ?TRACING) of
Expand Down Expand Up @@ -338,4 +341,4 @@ process_forward(ServerRef, Message) ->
catch
_:Error ->
lager:info("Error forwarding message ~p to process ~p: ~p", [Message, ServerRef, Error])
end.
end.

0 comments on commit 5e669f5

Please sign in to comment.