Configuration
This page details Configuration.
Basics
The runtime entry point is io.yupiik.fusion.framework.api.configuration.Configuration, an injectable bean with a single operation:
Optional<String> get(String key);
A typical way to use it is to declare a configuration model - a record marked with @RootConfiguration - and inject the generated instance directly:
@RootConfiguration("server")
public record ServerConfiguration(int port, String accessLogPattern) {}
This reads server.port, server.accessLogPattern (or their environment variables SERVER_PORT, SERVER_ACCESSLOGPATTERN) at injection time. See the configuration model
example for @Property, List, Map and nested models.
|
TIP
|
if you do use a nested configuration model coming from another jar, ensure it is flagged |
Sources
Sources are ordered: keys found in the first matching source win. Fusion ships these sources out of the box, in increasing priority:
-
system properties (
System.getProperty), -
environment variables (
System.getenv) - POSIX-normalized and uppercased (my.key->MY_KEY), -
secret directories (see below),
-
any additional
ConfigurationSourcebean you register.
You can plug your own values by defining a bean of type io.yupiik.fusion.framework.api.configuration.ConfigurationSource. It can be a class bean or a producer method:
@Bean
public ConfigurationSource mySource() {
return new ConfigurationSource() {
@Override
public String get(final String key) {
return "my-value".equals(key) ? "value" : null;
}
};
}
When several ConfigurationSource beans exist, they are sorted using @Order (lower values first) in the default Configuration implementation.
|
TIP
|
|
Secrets
Beyond system properties and environment variables, Fusion can read values from directories holding one file per secret.
-
Set the directories (comma separated) with
fusion.configuration.sources.secrets(or theFUSION_CONFIGURATION_SOURCES_SECRETSenvironment variable). -
If you mount them at
/var/run/secrets, they are picked up automatically when theKUBERNETES_SERVICE_HOSTenvironment variable is set. -
Each file name becomes the configuration key.
-
If you use
/var/run/secrets, bind the secrets in a directory named as your configuration prefix - for example/var/run/secrets/appif you useapp.*keys - to make the autodiscovery work automatically.
You can bind a _fusion.secrets.configuration.properties file in the same directory to refine how the directory name and children files recompose the key name. It accepts a folder.name.mode entry:
-
default(or empty): do nothing, take the file name as configuration key, -
concat: concatenate the directory name and file name separated by a dot (app/xxxxleads toapp.xxxxkey), -
strip: if the file name starts with the directory name, remove the directory name (with a dot suffix; for exampleapp/app.xxxxleads toxxxxkey).
|
TIP
|
configuration keys emitted before the "no prefix" root support used a leading |
Lifecycle hook
Sources registered after the Configuration singleton was already used are ignored until the Configuration singleton cache is invalidated. To register a source lazily and reliably, listen for the io.yupiik.fusion.framework.api.container.configuration.ConfigurationRegistration event:
public class MyListener {
public void onStart(@OnEvent final ConfigurationRegistration event) {
event.addSource().accept(new ConfigurationSource() {
// ...
});
}
}
Well-known keys
The following implicit keys are read directly from Configuration by the runtime modules (they are not declared through a configuration model):
| Key | Module | Default | Purpose |
|---|---|---|---|
|
|
fusion-api |
|
Register a JVM shutdown hook closing the container. |
|
|
fusion-api |
set |
Comma separated secret directories (see above). |
|
|
http-server |
|
Set |
|
|
http-server |
|
Deploy a separate monitoring server. |
|
|
http-server |
|
Port of the monitoring server. |
|
|
jsonrpc |
|
JSON-RPC endpoint path. |
|
|
jsonrpc |
|
Read the input reactively instead of using the request |
|
|
jsonrpc |
|
HTTP status for void/notification responses. |
|
|
jsonrpc |
|
JSON-RPC response content type. |
|
|
json |
- |
Mapper string buffer tuning. |
|
|
json |
- |
Mapper buffer tuning. |
|
|
json |
- |
Mapper buffer tuning. |
|
|
persistence |
|
Inject a |
|
|
cli |
|
Show options in usage. |
|
|
cli |
|
Application name in shell completion scripts. |
|
|
cli |
auto |
Which completion commands are registered ( |
|
|
cli |
- |
Bash completion candidate-mode inputs. |
Module specific keys (fusion.http-server.*, fusion.persistence.datasource.*, the JWT and operator keys) are documented in their own pages.