fun_with_flags
fun_with_flags copied to clipboard
[v2.0] Introduce entry point modules
Introduce the concept of entry point modules that a host application must implement in order to access the FunWithFlags API. This is adapted from what Ecto does with its Repo.
Requiring host applications to provide their own module allows the package to use a configuration callback function to obtain its config. This is an improvement over relying on the config.exs scripts, and it's consistent with the patterns that have been established in the Elixir ecosystem in the last few years. At the very least, it gives host applications more freedom on how their config can be read dynamically.
Note that in this PR, the entry points still rely on the global config from the config.exs files, but the plan is to move away from that. In the PR, the FunWithFlags.EntryPoint behaviour already defines a config/0 callback, but it's not really fleshed out nor used. A future PR will develop the idea further and use it as the way to configure an EntryPoint.
This change also allows host applications to use multiple FunWithFlags instances, where each EntryPoint represents an instance with its own config and potentially storage. This feature has been requested in the past.
For now, the legacy top-level API in the FunWithFlags module is preserved, but with deprecation warnings. This makes the entire test suite still pass (!), and allows for a gentler upgrade path for users of the package.