erllama_registry (erllama v0.1.0)

View Source

ETS-backed via callback for naming erllama_model gen_statems by binary model_id().

Atoms are unbounded global table entries; user-supplied model identifiers (e.g. coming from an HTTP request body in a front-end server) cannot safely be binary_to_atom/1'd. This registry lets a gen_statem be registered as

gen_statem:start_link({via, erllama_registry, ModelId}, ...)

with ModelId :: binary(), and looked up via whereis_name/1.

The registry is a tiny gen_server that owns a public ETS table. Lookups happen straight from ETS in the caller process, so the gen_server is never on the hot path.

Summary

Types

model_id()

-type model_id() :: binary().

Functions

all()

-spec all() -> [{model_id(), pid()}].

handle_call/3

handle_cast/2

handle_info/2

init/1

register_name(Name, Pid)

-spec register_name(model_id(), pid()) -> yes | no.

send(Name, Msg)

-spec send(model_id(), term()) -> pid().

start_link()

terminate/2

unregister_name(Name)

-spec unregister_name(model_id()) -> model_id().

whereis_name(Name)

-spec whereis_name(model_id()) -> pid() | undefined.