Skip to content

remmelt/dropwizard-consul-config-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Read Dropwizard configuration from Consul's KV store

Related blog post

Example run

Substitute your docker host where it says 192.168.59.103.

Start a Consul server:

docker run -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h node1 gliderlabs/consul-server -bootstrap -ui-dir /ui

Create a key: Visit the Consul ui: 192.168.59.103:8500/ui/#/dc1/kv/ and create a key named settings/someSetting with any value.

Now clone this repository and run the app:

git clone https://github.com/remmelt/dropwizard-consul-config-provider
cd dropwizard-consul-config-provider
mvn clean package
CONSUL_HOST="192.168.59.103" java -jar target/consul-config-provider.jar server src/main/resources/config.yml

The app should build and start up with a warning that I did not provide any health checks.

Let's see if it worked!

curl http://localhost:8080/

Or just open localhost:8080 in your browser.

someSetting: set from Consul's KV store
someOtherSetting: from config.yml
someSettingThatDoesNotExist: default_value_for_some_setting

Presto.