🔀 Dynamic is my second name!
In this release, all the private client configuration options become dynamic and may be resolved at runtime or at compile-time. It's defined by the presence of the otp_app
option.
If you set the otp_app
configuration the value lookup will follow this logic
OTP env value → Client value → Default value
Let's take a look at this example with private client MyClient
and :my_app
OTP application
# config/config.exs
config :my_app, MyClient, registry_url: "http://my-app.io"
# lib/my_client.ex
defmodule MyClient do
use Avrora.Client,
otp_app: :my_app,
registry_url: "http://never-used.com",
names_cache_ttl: 42
end
As the result, configuration values will look like this
MyClient.Config.registry_url() == "http://my-app.io" # (comes from runtime environment)
MyClient.Config.names_cache_ttl() == 42 # (comes from compile-time options)
MyClient.Config.registry_schemas_autoreg() == true # (comes from compile-time option defaults)
🚤 Bonus
Most of the generated Avrora.Client
code for Config
module gets rid of strings interpolation on runtime and moves it to the compile-rime and some hot paths were moved to compile-time.
Thanks a lot for this release to @juanperi 💙