See the OpenSergo Website for the official website of OpenSergo.
See the 中文文档 for document in Chinese.
- 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 planeOpenSergoClientclient = OpenSergoClientManager.get().getOrCreateClient(host, port);
// 2. Start the OpenSergo client.client.start();
// 3. Subscribe the config of the target (namespace, appName, kind)client.subscribeConfig(newSubscribeKey("default", "my-service", configKind),
newOpenSergoConfigSubscriber() {
@OverridepublicbooleanonConfigUpdate(SubscribeKeysubscribeKey, ObjectdataList) {
// Handle received config hereSystem.out.println("key: " + subscribeKey + ", data: " + dataList);
returntrue;
}
});