Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liemle3893/vertx-zookeeper
A thin, synchronous wrapper on vertx' Zookeeper Backend service discovery. Can be plug into any JVM based project.
https://github.com/liemle3893/vertx-zookeeper
java java8 service-discovery vertx zookeeper
Last synced: about 16 hours ago
JSON representation
A thin, synchronous wrapper on vertx' Zookeeper Backend service discovery. Can be plug into any JVM based project.
- Host: GitHub
- URL: https://github.com/liemle3893/vertx-zookeeper
- Owner: liemle3893
- License: apache-2.0
- Created: 2019-07-07T08:34:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-22T07:38:07.000Z (over 5 years ago)
- Last Synced: 2024-11-10T23:12:32.522Z (about 2 months ago)
- Topics: java, java8, service-discovery, vertx, zookeeper
- Language: Java
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
= Starter
A thin, synchronous wrapper on vertx' Zookeeper Backend service discovery. Can be plug into any JVM based project.
```groovy
repositories {
maven {
url "https://dl.bintray.com/liemle3893/Personal"
}
}
dependencies {
...
compile 'com.liemlhd.starter:vertx-zookeeper-starter:1.0'
...
}
```Example usage:
```java
public class App {public static void main(String[] args) throws Exception {
ServiceDiscovery discovery = new ZookeeperServiceDiscovery(Vertx.vertx(), createConfig());
// Service was create with at service type.
/**
* @see {@link com.liemlhd.starter.service_discovery.ServiceType}
* */
ServiceInfo serviceInfo = new ServiceInfo(() -> "test");
ServiceInfo.Address address = new ServiceInfo.Address();
address.setHost("localhost");
address.setPort(12345);
serviceInfo.setName("test");
serviceInfo.setAddress(address);
// Register it
Future promise = discovery.register(serviceInfo);
ServiceInfo s = promise.get();
System.out.println("registered service info: " + s);
// Do something with your service.
// Search for it
SearchCriteria searchCriteria = SearchCriteria.name("test");
Future> services = discovery.find( searchCriteria );
System.out.println("services = " + services);
// ...
// Do something with your services.
// Clean up
// Your service will be clean after it shutdown anyway
// but there a may be some delay, so for god's sake, DIY!
discovery.deregister(serviceInfo.getId()); // We do use serviceInfo.getId, so dont forget to saved your registered service info.
}public static ZkConfig createConfig() {
ZkConfig config = new ZkConfig();
config.setZookeeperHosts("localhost:2181");
return config;
}}
```