https://github.com/rikcarve/mp-config-consul
Eclipse microprofile config consul extension
https://github.com/rikcarve/mp-config-consul
consul java microprofile
Last synced: 5 months ago
JSON representation
Eclipse microprofile config consul extension
- Host: GitHub
- URL: https://github.com/rikcarve/mp-config-consul
- Owner: rikcarve
- License: mit
- Created: 2018-03-03T18:24:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T22:13:49.000Z (over 2 years ago)
- Last Synced: 2025-07-10T23:40:22.518Z (12 months ago)
- Topics: consul, java, microprofile
- Language: Java
- Size: 75.2 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/rikcarve/mp-config-consul/actions)
[](https://codecov.io/gh/rikcarve/mp-config-consul)
[](https://maven-badges.herokuapp.com/maven-central/ch.carve/mp-config-consul/)
# mp-config-consul
A eclipse microprofile config extension which uses [Consul](https://www.consul.io/) as source.
> This project has been integrated in https://github.com/microprofile-extensions/config-ext
>
> Currently under discussion to be integrated in [smallrye-config](https://github.com/smallrye/smallrye-config/issues/187)
>
> Nevertheless, this project will be maintained until further notice.
## Versions
0.10 -> Microprofile config 1.4 \
0.11 -> Microprofile config 2.0
## Overview
The eclipse microprofile config framework is a simple yet powerful configuration framework for Jakarta EE. But most implementations only provide the system/env properties or property files as configuration source. Consuls key/value store is a widely used configuration source, so this small library provides an ConfigSource implementation which takes the values from consul. For performance reasons, the config values are cached.
## Add dependency
```xml
ch.carve
mp-config-consul
0.15
```
## Configuration
Currently there are 6 values you can configure, either through Java system properties or environment variables:
* **configsource.consul.host** url of your (local) consul agent instance, e.g. "192.168.99.100", default empty, variable substitution available.
* **configsource.consul.hosts** list of consul servers, e.g. "192.168.99.100,192.168.99.101", default empty, variable substitution available.
* **configsource.consul.port** port of consul, e.g. "8500", default value is "8500", variable substitution available.
* **configsource.consul.validity** how long to cache values (in seconds), default is 30s
* **configsource.consul.prefix** key prefix to search value in consul, variable substitution available
* **configsource.consul.list-all** whether getProperties() should query consul for all kv pairs, default is false
* **configsource.consul.token** token that will be used to retrieve key/values from consul. Default is empty and retrieval is done without token.
> Note: Since mp-config-consul 0.11 (mp-config 2.0) variable substitution is now part of microprofile-config (property expressions)
> Note: these config values cannot be set in Quarkus application.properties, you need to pass them as JVM arguments like this `-Dconfigsource.consul.host=consul.mycompany.com` or through environment variables.
> Note: if both host and hosts are empty, this configsource is disabled!
## Ordinal
Config sources have priorities called ordinal. This config source has ordinal 550, but can be overriden with setting 'config_ordinal' in this source (including prefix if defined)
## Links
* https://microprofile.io/project/eclipse/microprofile-config
* https://github.com/rikcarve/consulkv-maven-plugin
* https://github.com/rikcarve/mp-config-db