[v2.0] Introduce entry point modules #165
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, theFunWithFlags.EntryPoint
behaviour already defines aconfig/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.