Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2.0] Introduce entry point modules #165

Draft
wants to merge 5 commits into
base: v2
Choose a base branch
from
Draft

Conversation

tompave
Copy link
Owner

@tompave tompave commented Dec 15, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant