Lamina.Server.get
get
, go back to Lamina.Server module for more information.
get(module, config_key)
Specs
get(module(), config_key()) :: {:ok, value()} | {:error, ConfigNotFoundError.t() | NotRegisteredError.t()}
Retrieve a configuration value.
This is the function which is called by the dynamically generated
configuration functions in the configuration module, ie calling
MyHttpServer.Config.listen_port()
and
Lamina.Server.get(MyHttpServer.Config, :listen_port)
are functionally
identical.
Looks the server pid and ETS table up in Lamina registry, then queries the
table for the best match configuration value. In most cases this should allow
the configuration value to be returned quickly without having to wait for a
GenServer round-trip as both Registry
and the server use ETS tables with
read concurrency enabled.
The only case where a call needs to be made to the server is when the best
configuration value is marked as :volatile
by the provider - ie the value
can theoretically be different each time it's called. This is the case for
the Env
and ApplicationEnv
providers, as both of these provide wrappers
around a potentially volatile store.
Example
iex> Server.get(MyHttpServer.Config, :listen_port)
...> {:ok, 4000}