new patch: Add plugin support for alternative name lookup

Ulf Wiger ulf.wiger@REDACTED
Mon Jan 17 16:12:52 CET 2011


git fetch git://github.com/uwiger/otp.git uw_extending_gen

Note that I've not updated documentation. If people don't 
like the idea, I won't waste my time doing so, but otherwise, I 
will follow up with documentation changes as well.

BR,
Ulf


commit 22453671179dadf7204675438cf36edde137f945
Author: Ulf Wiger <ulf.wiger@REDACTED>
Date:   Mon Jan 17 15:47:00 2011 +0100

    Add plugin support for alternative name lookup
    
    OTP behaviour instances (gen_server, gen_fsm, gen_event) can currently
    register themselves either locally or globally, and the behaviour
    libraries (including gen.erl) support both addressing methods, as well
    as the normal Pid and {Name, Node}.
    
    However, there are alternative registry implementations - e.g. gproc -
    and one can well imagine other ways of locating a behaviour instance,
    e.g. on a node connected only via a TCP tunnel, rather than via
    Distributed Erlang. In all these cases, one needs to write extra code
    to identify the behaviour instance, even though the instance itself
    need not be aware of how it is located.
    
    This patch introduces a new way of locating a behaviour instance:
    {via, Module, Name}.
    
    Module is expected to export a subset of the functions in global.erl,
    namely:
    
    register_name(Name, Pid) -> yes | no
    whereis_name(Name)  -> pid() | undefined
    unregister_name(Name) -> ok
    send(Name, Msg) -> Pid
    
    Semantics are expected to be the same as for global.erl
    
    This can be used in all places where {global, Name} is accepted.
    
    In this patch, the test suites gen_server_SUITE, gen_fsm_SUITE and
    gen_event_SUITE have been extended, but documentation has not been
    updated. This will be done if there is agreement that the idea is
    good.


Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com





More information about the erlang-patches mailing list