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

Configuration transformers #11

Open
ferdinand-beyer opened this issue Aug 6, 2023 · 1 comment
Open

Configuration transformers #11

ferdinand-beyer opened this issue Aug 6, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ferdinand-beyer
Copy link
Owner

Many features that more complex DI frameworks provide can be done in init by simply transforming the configuration.

For example, consider Spring's @Conditional annotation, which will include beans only when certain conditions are met. Common examples are the presence of a certain class on the classpath (e.g. to auto-configure adapter beans) or beans of certain types (e.g. to provide defaults).

In init, we can simply discover the configuration, then remove components whose prerequisites are not met.

How do we configure such conditions? We can use tags, and/or add custom keys to components (components are just maps). When discovering components from vars, we can access the var's metadata.

How do we configure transformers? Since discovery + starting are two separate steps, we can transform the configuration before starting the system.

Explore:

  • Would it be convenient to discover transformers automatically, e.g. find components that are transformers?
  • Maybe provide a set of curated transformers?
    • conditionals
    • order-only dependencies
    • CDI-style alternatives
    • components that take the system map itself
    • etc.

This could be a convenient way for devs to pick the "features" they want, and be inspired to explore their own.

@ferdinand-beyer ferdinand-beyer added the enhancement New feature or request label Aug 6, 2023
@ferdinand-beyer
Copy link
Owner Author

Maybe we can implement more of init's core with transformers as well:

  • start-fn: Take a component's config, a partial system map, and a sequence of resolved keys for its dependencies
    • Allows start functions to be more generic
  • Transformation: Wrap start function to pull required arguments from the partial system map
  • :init/inject: Parse spec into data, have a transformer that compiles arguments from that

By pulling this apart and being more modular, we enable use cases that we might not have thought of before!

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

No branches or pull requests

1 participant