diff --git a/README.md b/README.md index 44f5801..27209a4 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ See the [中文文档](https://opensergo.io/zh-cn/) for document in Chinese. 1. Add dependency in Maven `pom.xml`: -```xml +``` xml io.opensergo @@ -29,20 +29,28 @@ See the [中文文档](https://opensergo.io/zh-cn/) for document in Chinese. 2. Subscribe data from OpenSergo control plane: -```java +``` java // 1. Create client with remote host and port of OpenSergo control plane OpenSergoClient client = new OpenSergoClient(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() { +// 3. Prepare for subscribing the config of the target (namespace, appName, kind) +// 3.1 Create the SubscribeKey of your target +SubscribeKey subscribeKey = new SubscribeKey("default", "my-service", configKind); +// 3.2 Create the SubscribeInfo of your target by subscribeKey +OpensergoClientSubscribeInfo subscribeInfo = new OpensergoClientSubscribeInfo(subscribeKey); +// 3.3 Add a Subscriber for you target which would listen changes of target +subscribeInfo.addSubscriber(new OpenSergoConfigSubscriber() { @Override public boolean onConfigUpdate(SubscribeKey subscribeKey, Object dataList) { - // Handle received config here + // TODO Handle received config here System.out.println("key: " + subscribeKey + ", data: " + dataList); return true; } }); + +// 4. Register into OpenSergoClient the SubscribeInfo which was builded above. +// And then the client will subscribe config automatic. +client.registerSubscribeInfo(subscribeInfo); ``` \ No newline at end of file