-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Eugene Strokin edited this page Apr 30, 2021
·
2 revisions
Dynocon is a library for dynamic configuration. It supports multiple sources of the configuration properties. Properties sources could be combined into a cascading hierarchy and be polled periodically. The changes provided to the code automatically, without restarting the application.
Configuration properties read is lock-free. All the polling and value updates are happening in separate threads.
Maven:
<dependency>
<groupId>com.comcast</groupId>
<artifactId>dynocon-core</artifactId>
<version>LATEST</version>
</dependency>
Add a service.json
file into /opt
folder. The content of the file is JSON with properties and values:
{
"myPropertyName": "value1",
"complexProperty": {
"prop1": "Hello world",
"prop2": 777
}
}
public static final Property<String> MY_PROPERTY = new Property<>("myPropertyName", String.class);
... SNIP ...
Assert.assertEquals("value1", MY_PROPERTY.get());
public static final Property<String> MY_OTHER_PROPERTY = new Property<>("myOtherPropertyName", String.class).ifNull("SOME DEFAULT VALUE");
... SNIP ...
Assert.assertEquals("SOME DEFAULT VALUE", MY_OTHER_PROPERTY.get());
public class MyComplexConfig {
private String prop1;
private Integer prop2;
... GETTERS AND SETTERS ...
}
... SNIP ...
public static final Property<MyComplexConfig> MY_COMPLEX_PROPERTY = new Property<>("complexProperty", MyComplexConfig.class);
... SNIP ...
Assert.assertEquals("Hello world", MY_COMPLEX_PROPERTY.get().getProp1());
Assert.assertEquals(777, MY_COMPLEX_PROPERTY.get().getProp2());
Open service.json
file and update the value of any JSON field. You should see the change reflected in your code in less than 30 seconds.
- System and environment variables as the source of the configuration properties.
- Old fashioned
.properties
files as the source of the configuration properties. - URL as the source of the configuration properties.
- Adding your own source of the configuration properties.
- Adjusting polling interval.
- Configuring your property sources.
- AWS DyanmoDB table as a configuration source
- Dynocon for Spring Boot