|
1 | | -# OpenSergo Java SDK |
| 1 | +<img src="https://user-images.githubusercontent.com/9434884/197435179-bbda0a82-6bae-485e-ac1a-490fee91a002.png" alt="OpenSergo Logo" width="50%"> |
| 2 | + |
| 3 | +# OpenSergo Java SDK |
| 4 | + |
| 5 | +[](https://github.com/opensergo/opensergo-java-sdk/actions/workflows/ci.yml) |
| 6 | +[](https://search.maven.org/search?q=g:%22io.opensergo%22%20AND%20a:%22opensergo-java-sdk%22) |
| 7 | +[](https://www.apache.org/licenses/LICENSE-2.0.html) |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +## Documentation |
| 12 | + |
| 13 | +See the [OpenSergo Website](https://opensergo.io/) for the official website of OpenSergo. |
| 14 | + |
| 15 | +See the [中文文档](https://opensergo.io/zh-cn/) for document in Chinese. |
| 16 | + |
| 17 | +## Quick Start |
| 18 | + |
| 19 | +1. Add dependency in Maven `pom.xml`: |
| 20 | + |
| 21 | +```xml |
| 22 | +<!-- replace here with the latest version --> |
| 23 | +<dependency> |
| 24 | + <groupId>io.opensergo</groupId> |
| 25 | + <artifactId>opensergo-java-sdk</artifactId> |
| 26 | + <version>0.1.0-alpha</version> |
| 27 | +</dependency> |
| 28 | +``` |
| 29 | + |
| 30 | +2. Subscribe data from OpenSergo control plane: |
| 31 | + |
| 32 | +```java |
| 33 | +// 1. Create client with remote host and port of OpenSergo control plane |
| 34 | +OpenSergoClient client = new OpenSergoClient(host, port); |
| 35 | +// 2. Start the OpenSergo client. |
| 36 | +client.start(); |
| 37 | + |
| 38 | +// 3. Subscribe the config of the target (namespace, appName, kind) |
| 39 | +client.subscribeConfig(new SubscribeKey("default", "my-service", configKind), |
| 40 | + new OpenSergoConfigSubscriber() { |
| 41 | + @Override |
| 42 | + public boolean onConfigUpdate(SubscribeKey subscribeKey, Object dataList) { |
| 43 | + // Handle received config here |
| 44 | + System.out.println("key: " + subscribeKey + ", data: " + dataList); |
| 45 | + return true; |
| 46 | + } |
| 47 | + }); |
| 48 | +``` |
0 commit comments