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-parent
Last Version

Last Version

0.3.4
Release Date

Release Date

Type

Type

pom
Description

Description

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

Project URL

https://github.com/scalecube/config
Source Code Management

Source Code Management

https://github.com/scalecube/config

Download config-parent

Filename Size
config-parent-0.3.4.pom 12 KB
Browse

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • config
  • config-mongo
  • config-http-server
  • config-examples
  • config-vault

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.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