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

Adopt MicroProfile Config / SmallRye Config for configuration management #695

Open
nscuro opened this issue Oct 19, 2024 · 0 comments · May be fixed by #696
Open

Adopt MicroProfile Config / SmallRye Config for configuration management #695

nscuro opened this issue Oct 19, 2024 · 0 comments · May be fixed by #696
Milestone

Comments

@nscuro
Copy link
Collaborator

nscuro commented Oct 19, 2024

Alpine's current Config API is very simplistic, which is fine for the majority of use cases.

While working on Hyades, we're encountering increasingly more situations where hierarchical and repeatable configs are required. For example, to configure multiple Kafka consumers, something like the following is done:

kafka.processor.foo.max.concurrency=6
kafka.processor.foo.processing.order=key
kafka.processor.bar.max.concurrency=3
kafka.processor.bar.processing.order=partition

Creating redundant Config.Keys for each processor is impractical. Building a generic solution on top of this is possible, however it's complicated by the need to have values overwritable through multiple ways (i.e. application.properties and environment variables).

Further, we're finding that a mechanism to validate configuration on startup would be beneficial. As multiple subsystems are initialized one after another, users usually don't get to know about invalid configuration until the subsystem accessing it runs into an error.

I'm proposing to adopt a more capable config management solution, specifically MicroProfile Config.

SmallRye Config is currently the best / most maintained implementation of MicroProfile Config. It's used by Quarkus, but can be used without CDI (which is important since Alpine doesn't have it).

Applications based on Alpine can customize SmallRye Config to their needs, e.g. to add additional sources, or register ConfigMappings, using the SPI.

Another benefit is that SmallRye Config supports validation using standard bean validation annotations.

The introduction of SmallRye Config can be achieved in a backward compatible manner, where SR replaces the current Properties that back Alpine's Config class. Existing methods of Config can simply delegate to SR.

To gain direct access to SmallRyeConfig, we can expose it as delegate. For example, to access a ConfigMapping, users might do:

Config.getInstance().getDelegate().unwrap(SmallRyeConfig.class).getConfigMapping(MyConfigMapping.class)
@nscuro nscuro added this to the 3.2.0 milestone Oct 19, 2024
nscuro added a commit to nscuro/Alpine that referenced this issue Oct 19, 2024
@nscuro nscuro linked a pull request Oct 19, 2024 that will close this issue
nscuro added a commit to nscuro/Alpine that referenced this issue Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant