[erlang-questions] gen behaviors and global groups

Serge Aleynikov <>
Mon Aug 25 01:26:30 CEST 2008


Little bugfix in my previous posting below:

Serge Aleynikov wrote:
> Currently when using gen_* behaviors the way to reference a 
> locally/globally registered server is by providing a server name in the 
> form:
> 
> 	ServerName = {local,Name} | {global,GlobalName}
> 
> When the cluster of nodes is partitioned into global groups, there 
> doesn't seem to be a way to instruct a server to do a global name lookup 
> in a specific global group.  Unless I am missing something, it looks 
> like the gen behaviors should allow this types of server names:
> 
> 	ServerName = {local,Name} | {global,GlobalName} |
>                       {{group, Group}, GlobalName}
> 
> Without this third option one would have to do something like this in 
> order to call a server registered in group G:
> 

my_function({{group, Group}, Name}, Args) ->
     case global_group:whereis_name(Group, Name) of
     Pid when is_pid(Pid) ->
         my_function(Pid, Args);
     undefined ->
	{error, noproc}
     end;
my_function(Name, Args) ->
     gen_server:call(Name, {my_function, Args}).

> 
> Shouldn't gen.erl handle this sort of name lookups automatically?
> 
> Serge
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list