get config from zookeeper #81

Closed
ksaritek opened this Issue Jun 16, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@ksaritek
Contributor

ksaritek commented Jun 16, 2014

is there a possibilty to create config from zookeeper instead of file on classpath?

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 17, 2014

Owner

I didn't know about Zookeeper. OWNER is able to load configuration from standard URLs, which includes "file:", "ftp:", "http[s]:" etc.
If zookeeper supports exposing its configuration via an URL this might work. Otherwise we need to add a "zookeeper:" URL as we did for "classpath:". I got a push request to use URI instead of URL recently that may be part of this implementation, since "zookeeper:" URL may throw an exception if used in the constructor of a URL, while should be valid for URI.
OWNER defines an method called Factory.registerLoader() and a Loader Interface, to allow users to define new kind of loaders, i.e. a ZookeperLoader object.

Owner

lviggiano commented Jun 17, 2014

I didn't know about Zookeeper. OWNER is able to load configuration from standard URLs, which includes "file:", "ftp:", "http[s]:" etc.
If zookeeper supports exposing its configuration via an URL this might work. Otherwise we need to add a "zookeeper:" URL as we did for "classpath:". I got a push request to use URI instead of URL recently that may be part of this implementation, since "zookeeper:" URL may throw an exception if used in the constructor of a URL, while should be valid for URI.
OWNER defines an method called Factory.registerLoader() and a Loader Interface, to allow users to define new kind of loaders, i.e. a ZookeperLoader object.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Oct 1, 2014

Owner

Hi.

I just pushed on master some code to get zookeeper configuration.

It doesn't support the hot reload mechanism yet, but I hope it will in future (no schedule for this yet).

See ZooKeeperLoaderTest.java unit test as example.

There are three steps you need to do:

// 1st step: define the ZooKeeperConfig class:

@Sources("zookeeper://127.0.0.1:65403/test")
public static interface ZooKeeperConfig extends Config {
    String thanks();
    List<String> greetings();
    String notAvailable();
}

// 2nd step: register a loader to handle the "zookeeper://" URL: 

ConfigFactory.registerLoader(new ZooKeeperLoader());

// 3rd step: use things as usual.

ZooKeeperConfig cfg = ConfigFactor.create(ZooKeeperConfig.class);
Owner

lviggiano commented Oct 1, 2014

Hi.

I just pushed on master some code to get zookeeper configuration.

It doesn't support the hot reload mechanism yet, but I hope it will in future (no schedule for this yet).

See ZooKeeperLoaderTest.java unit test as example.

There are three steps you need to do:

// 1st step: define the ZooKeeperConfig class:

@Sources("zookeeper://127.0.0.1:65403/test")
public static interface ZooKeeperConfig extends Config {
    String thanks();
    List<String> greetings();
    String notAvailable();
}

// 2nd step: register a loader to handle the "zookeeper://" URL: 

ConfigFactory.registerLoader(new ZooKeeperLoader());

// 3rd step: use things as usual.

ZooKeeperConfig cfg = ConfigFactor.create(ZooKeeperConfig.class);
@ksaritek

This comment has been minimized.

Show comment
Hide comment
@ksaritek

ksaritek Oct 2, 2014

Contributor

Thanks for help, that was my firts pull request :)

On Thu, Oct 2, 2014 at 2:12 AM, Luigi R. Viggiano notifications@github.com
wrote:

Hi.

I just pushed on master some code to get zookeeper configuration. It
doesn't support the hot reload mechanism yet, but I hope it will in future
(no schedule for this yet).

See ZooKeeperLoaderTest.java
https://github.com/lviggiano/owner/blob/master/owner-loaders/src/test/java/org/aeonbits/owner/loaders/ZooKeeperLoaderTest.java
unit test as example.

There are two steps you need to do:

// 1st step: define the ZooKeeperConfig class:

@sources("zookeeper://127.0.0.1:65403/test")
public static interface ZooKeeperConfig extends Config {
String thanks();
List greetings();
String notAvailable();
}
// 2nd step: register a loader to handle the "zookeeper://" URL: ConfigFactory.registerLoader(new ZooKeeperLoader());
// 3rd use things as usual.
ZooKeeperConfig cfg = ConfigFactor.create(ZooKeeperConfig.class);


Reply to this email directly or view it on GitHub
#81 (comment).

Contributor

ksaritek commented Oct 2, 2014

Thanks for help, that was my firts pull request :)

On Thu, Oct 2, 2014 at 2:12 AM, Luigi R. Viggiano notifications@github.com
wrote:

Hi.

I just pushed on master some code to get zookeeper configuration. It
doesn't support the hot reload mechanism yet, but I hope it will in future
(no schedule for this yet).

See ZooKeeperLoaderTest.java
https://github.com/lviggiano/owner/blob/master/owner-loaders/src/test/java/org/aeonbits/owner/loaders/ZooKeeperLoaderTest.java
unit test as example.

There are two steps you need to do:

// 1st step: define the ZooKeeperConfig class:

@sources("zookeeper://127.0.0.1:65403/test")
public static interface ZooKeeperConfig extends Config {
String thanks();
List greetings();
String notAvailable();
}
// 2nd step: register a loader to handle the "zookeeper://" URL: ConfigFactory.registerLoader(new ZooKeeperLoader());
// 3rd use things as usual.
ZooKeeperConfig cfg = ConfigFactor.create(ZooKeeperConfig.class);


Reply to this email directly or view it on GitHub
#81 (comment).

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Oct 2, 2014

Owner

Cool thanks!

Owner

lviggiano commented Oct 2, 2014

Cool thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment