Module local

A Local Name Registration Facility.

Copyright © 2014, Takeru Ohta <phjgt308@gmail.com>

Description

A Local Name Registration Facility

Data Types

name()

name() = {name_server_name(), process_name()}

name_server_name()

name_server_name() = atom()

otp_name()

otp_name() = {local, Name::atom()} | {global, Name::term()} | {via, module(), Name::term()}

otp_ref()

otp_ref() = (Name::atom()) | {Name::atom(), node()} | {global, Name::term()} | {via, module(), Name::term()} | pid()

process_name()

process_name() = term()

Function Index

name_server_child_spec/1Equivalent to name_server_child_spec(Name, Name, 5000).
name_server_child_spec/3Returns the child spec for a local name server that is used in embedded mode.
otp_name/1Returns OTP compatible name.
register_name/2Locally assocates the name Name with a pid Pid.
send/2Sends the message Msg to the pid locally registered as Name
start_name_server/1Starts a name server process.
stop_name_server/1Stops the name server ServerName
unregister_name/1Removes the locally registered name Name
whereis_name/1Returns the pid with the locally registered name Name
which_name_servers/0Returns a list of running name server.
which_processes/1Returns a list of registered process.
which_processes/2Returns a list of registered process that has a name which matches the pattern Pattern

Function Details

name_server_child_spec/1

name_server_child_spec(Name::name_server_name()) -> supervisor:child_spec()

Equivalent to name_server_child_spec(Name, Name, 5000).

name_server_child_spec/3

name_server_child_spec(ChildId, ServerName, Shutdown) -> ChildSpec

Returns the child spec for a local name server that is used in embedded mode.

To embed a local name server in your application, you can simply add ChildSpec to your supervision tree.

otp_name/1

otp_name(Name::name()) -> otp_name()

Returns OTP compatible name

register_name/2

register_name(Name::name(), Pid::pid()) -> yes | no

Locally assocates the name Name with a pid Pid.

Let NameServer is element(1, Name), the registered name is limited to the name server NameServer scope.

Assumes that the name server is already started, crashes otherwise.

The function returns yes if successful, no if it failes. For example, no is returned if an attempt is made to register an already registered process or to register a process with a name that is already in use.

send/2

send(Name::name(), Msg::term()) -> pid()

Sends the message Msg to the pid locally registered as Name

Failure: If Name is not a locally registered name, the calling function will exit with reason {badarg, {Name, Msg}}

start_name_server/1

start_name_server(ServerName::name_server_name()) -> ok | {error, Reason}

Starts a name server process

The process is registered locally as ServerName using register/2.

If the process is successfully started the function returns ok.

If there already exists a process with the specified ServerName the function returnes {error, already_present}.

stop_name_server/1

stop_name_server(ServerName::name_server_name()) -> ok | {error, Reason}

Stops the name server ServerName

If successful, the function returns ok. If the name server identified by ServerName does not exist, the function returns {error, not_found}.

unregister_name/1

unregister_name(Name::name()) -> ok

Removes the locally registered name Name

whereis_name/1

whereis_name(Name::name()) -> pid() | undefined

Returns the pid with the locally registered name Name

Returns undefined if the name is not locally registered.

which_name_servers/0

which_name_servers() -> [name_server_name()]

Returns a list of running name server

which_processes/1

which_processes(NameServer::name_server_name()) -> [{process_name(), pid()}]

Returns a list of registered process

which_processes/2

which_processes(NameServer::name_server_name(), ProcNamePattern::ets:match_pattern()) -> [{process_name(), pid()}]

Returns a list of registered process that has a name which matches the pattern Pattern


Generated by EDoc, Oct 19 2017, 06:44:03.