io.scalecube:config

ScaleCube Config is a configuration management library for JVM based distributed applications.

License

License

Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

io.scalecube
ArtifactId

ArtifactId

config
Last Version

Last Version

0.4.15
Release Date

Release Date

Type

Type

jar
Description

Description

ScaleCube Config is a configuration management library for JVM based distributed applications.

Download config

How to add to project

<!-- https://jarcasting.com/artifacts/io.scalecube/config/ -->
<dependency>
    <groupId>io.scalecube</groupId>
    <artifactId>config</artifactId>
    <version>0.4.15</version>
</dependency>
// https://jarcasting.com/artifacts/io.scalecube/config/
implementation 'io.scalecube:config:0.4.15'
// https://jarcasting.com/artifacts/io.scalecube/config/
implementation ("io.scalecube:config:0.4.15")
'io.scalecube:config:jar:0.4.15'
<dependency org="io.scalecube" name="config" rev="0.4.15">
  <artifact name="config" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.scalecube', module='config', version='0.4.15')
)
libraryDependencies += "io.scalecube" % "config" % "0.4.15"
[io.scalecube/config "0.4.15"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.7

test (10)

Group / Artifact Type Version
com.fasterxml.jackson.datatype : jackson-datatype-jdk8 jar
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar
com.google.guava : guava jar 29.0-jre
org.junit.jupiter : junit-jupiter-engine jar 5.1.1
org.junit.jupiter : junit-jupiter-params jar 5.1.1
org.mockito : mockito-junit-jupiter jar 2.27.0
org.hamcrest : hamcrest-all jar 1.3
org.hamcrest : hamcrest-core jar 1.3
org.apache.logging.log4j : log4j-slf4j-impl jar 2.13.3
org.apache.logging.log4j : log4j-core jar 2.13.3

Project Modules

There are no modules declared in this project.

ScaleCube Config

Maven Central

ScaleCube Config is a configuration management library for JVM based distributed applications.

It provides the following functionality:

  • Dynamic typed properties
  • Register callbacks on property changes
  • Object binding for grouping properties
  • Extensible range of supported property sources (environment variables, program arguments, classpath, property files, mongodb, git repository, zookeeper etc.)
  • Support centralized hierarchical property sources
  • Control over order of applying different property sources
  • Audit log of property changes
  • Expose properties and settings via JMX and/or HTTP

Usage

Configure and create configuration registry instance:

Predicate<Path> predicate = path -> path.toString().endsWith(".props"); // match by .props extension
ConfigRegistrySettings settings = ConfigRegistrySettings.builder()
        .addLastSource("classpath", new ClassPathConfigSource(predicate))
        .addLastSource("configDirectory", new DirectoryConfigSource("conf" /* base path */, predicate))
        .addListener(new Slf4JConfigEventListener()) // print all property changes to log
        .build();
ConfigRegistry configRegistry = ConfigRegistry.create(settings);

Get dynamic typed configuration property:

LongConfigProperty timeoutProperty = configRegistry.longProperty("http.request-timeout");
long timeout = timeoutProperty.get(30 /* default value */);

Register callbacks on property modifications:

timeoutProperty.addCallback((oldValue, newValue) -> 
        System.out.println("Timeout value changed to " + newValue));

Register validators on property values (only values which passed all validators will be applied):

timeoutProperty.addValidator(val -> val >= 0); // timeout can't be negative

Utilize object binding:

// Define configuration class
public interface MyConfig {
  private boolean meaning;
  private int answer;
  private double realAnswer;
  ...
}

// myapp.config.meaning=true
// myapp.config.answer=42
// myapp.config.realAnswer=42.000000000000001
ObjectConfigProperty<MyConfig> config = configRegistry.objectProperty("myapp.config", MyConfig.class);

// Get current config values
MyConfig currentConfig = config.value(MyConfig.defaultValue() /* or default */);

// Register callback (called only once per config reload even when several properties changed)
config.addCallback((oldConfig, newConfig) -> 
        System.out.println("MyConfig updated from " + oldConfig + " to " + newConfig)); 
        
// Register validator
// If meaning is present, an answer should be at least as big as the answer  
config.addValidator(val -> val.meaning && val.answer >= 42);     

Start embedded HTTP server which exposes configuration endpoints:

ConfigRegistryHttpServer.create(configRegistry, 5050); // starts http server on port 5050

After HTTP server is started explore configuration registry by browsing following endpoints:

See more examples at config-examples module.

Maven

Binaries and dependency information for Maven can be found at http://search.maven.org.

Change history and version numbers can be found at CHANGES.md.

Maven dependency:

<dependency>
  <groupId>io.scalecube</groupId>
  <artifactId>config</artifactId>
  <version>x.y.z</version>
</dependency>

<!-- For exposing config HTTP endpoints -->
<dependency>
  <groupId>io.scalecube</groupId>
  <artifactId>config-http-server</artifactId>
  <version>x.y.z</version>
</dependency>

<!-- For MongoDB integration (beta version) -->
<dependency>
  <groupId>io.scalecube</groupId>
  <artifactId>config-mongo</artifactId>
  <version>x.y.z</version>
</dependency>

Bugs and Feedback

For bugs, questions and discussions please use the GitHub Issues.

License

Apache License, Version 2.0

io.scalecube

SCΛLΞ CUBΞ

⚛ High-Speed ⚛ Cloud-Native ⚛ Reactive Microservices ⚛

Versions

Version
0.4.15
0.4.14
0.4.13
0.4.4
0.4.4-RC3
0.4.4-RC2
0.4.4-RC1
0.4.3
0.4.2
0.4.0
0.4.0-RC8
0.4.0-RC7
0.4.0-RC6
0.4.0-RC5
0.4.0-RC4
0.4.0-RC3
0.4.0-RC2-RC1
0.3.14
0.3.13
0.3.12
0.3.11
0.3.10
0.3.9
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0