opensergo-java-sdk
opensergo-java-sdk copied to clipboard
OpenSergo Java SDK

OpenSergo Java SDK
Introduction
Documentation
See the OpenSergo Website for the official website of OpenSergo.
See the 中文文档 for document in Chinese.
Quick Start
- Add dependency in Maven
pom.xml
:
<!-- replace here with the latest version -->
<dependency>
<groupId>io.opensergo</groupId>
<artifactId>opensergo-java-sdk</artifactId>
<version>0.1.0</version>
</dependency>
- Subscribe data from OpenSergo control plane:
// 1. Create client with remote host and port of OpenSergo control plane
OpenSergoClient client = OpenSergoClientManager.get().getOrCreateClient(host, port);
// 2. Start the OpenSergo client.
client.start();
// 3. Subscribe the config of the target (namespace, appName, kind)
client.subscribeConfig(new SubscribeKey("default", "my-service", configKind),
new OpenSergoConfigSubscriber() {
@Override
public boolean onConfigUpdate(SubscribeKey subscribeKey, Object dataList) {
// Handle received config here
System.out.println("key: " + subscribeKey + ", data: " + dataList);
return true;
}
});