Module dev_local_name.erl¶
A device for registering and looking up local names.
Description¶
This device uses the node message to store a local cache of its known names, and the typical non-volatile storage of the node message to store the names long-term.
Function Index¶
default_lookup/4* | Handle all other requests by delegating to the lookup function. |
direct_register/2 | Register a name without checking if the caller is an operator. |
find_names/1* | Returns a message containing all known names. |
generate_test_opts/0* | |
http_test/0* | |
info/1 | Export only the lookup and register functions. |
load_names/1* | Loads all known names from the cache and returns the new node message
with those names loaded into it. |
lookup/3 | Takes a key argument and returns the value of the name, if it exists. |
lookup_opts_name_test/0* | |
no_names_test/0* | |
register/3 | Takes a key and value argument and registers the name. |
register_test/0* | |
unauthorized_test/0* | |
update_names/2* | Updates the node message with the new names. |
Function Details¶
default_lookup/4 *¶
default_lookup(Key, X2, Req, Opts) -> any()
Handle all other requests by delegating to the lookup function.
direct_register/2¶
direct_register(Req, Opts) -> any()
Register a name without checking if the caller is an operator. Exported for use by other devices, but not publicly available.
find_names/1 *¶
find_names(Opts) -> any()
Returns a message containing all known names.
generate_test_opts/0 *¶
generate_test_opts() -> any()
http_test/0 *¶
http_test() -> any()
info/1¶
info(Opts) -> any()
Export only the lookup
and register
functions.
load_names/1 *¶
load_names(Opts) -> any()
Loads all known names from the cache and returns the new node message
with those names loaded into it.
lookup/3¶
lookup(X1, Req, Opts) -> any()
Takes a key
argument and returns the value of the name, if it exists.
lookup_opts_name_test/0 *¶
lookup_opts_name_test() -> any()
no_names_test/0 *¶
no_names_test() -> any()
register/3¶
register(X1, Req, Opts) -> any()
Takes a key
and value
argument and registers the name. The caller
must be the node operator in order to register a name.
register_test/0 *¶
register_test() -> any()
unauthorized_test/0 *¶
unauthorized_test() -> any()
update_names/2 *¶
update_names(LocalNames, Opts) -> any()
Updates the node message with the new names. Further HTTP requests will use this new message, removing the need to look up the names from non-volatile storage.