Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Latest commit

 

History

History
56 lines (41 loc) · 1.68 KB

README.md

File metadata and controls

56 lines (41 loc) · 1.68 KB

protoconf-java - A Java SDK for protoconf

License GitHub release

protoconf-java is the java sdk for protoconf .

Java Versions

Java 8 or above is required.

Download

Maven

Add dependency to pom.xml

<dependency>
  <groupId>com.yoozoo.protoconf</groupId>
  <artifactId>protoconf-java</artifactId>
  <version>${protoconf-java-version}</version>
</dependency>

Usage

// set app token
String appToken = "U2FsdGVkX1+EGNROfb41wAhtOumHKQPkli1FEL54C/U=";
EtcdReader etcdReader = new EtcdReader();
etcdReader.setAppToken(appToken);

// connect to etcd
ConfigurationReader configurationReader = new ConfigurationReader(etcdReader);

// fill in etcd values to config instance
configurationReader.config(Configuration.instance());

// watch config changes
Configuration.instance().watch_name(new ChangeListener() {
    @Override
    public void onChange(String newValue) {
        System.out.println("name has been changed to: " + newValue);
    }
});
configurationReader.watchKeys(Configuration.instance());

// get config value
dataSource.setUrl(Configuration.instance().get_mysqlDsn());
dataSource.setUsername(Configuration.instance().get_username());
dataSource.setPassword(Configuration.instance().get_password());

License

protoconf-java is under the Apache 2.0 license. See the LICENSE file for details.