[erlang-questions] gen behaviors and global groups

Serge Aleynikov saleyn@REDACTED
Thu Aug 28 13:50:42 CEST 2008


Since I haven't seen any follow-up on this question, I'd like to 
rephrase it.  Is there any drawback in applying the attached patch that 
would allow all gen behaviors to specify registered names in given 
global groups?

Serge

Serge Aleynikov wrote:
> 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

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gen.erl.diff
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080828/f670bb88/attachment.ksh>


More information about the erlang-questions mailing list