From a960158c44d6a86fa1d4dbc1cbd407cdc34660ef Mon Sep 17 00:00:00 2001 From: Jiangnan Jia Date: Sat, 3 Dec 2022 22:04:20 +0800 Subject: [PATCH] Remove OpenSergoClientSubscribeInfo.java Signed-off-by: Jiangnan Jia --- .../java/io/opensergo/OpenSergoClient.java | 21 +++---- .../OpenSergoClientSubscribeInfo.java | 62 ------------------- 2 files changed, 7 insertions(+), 76 deletions(-) delete mode 100644 src/main/java/io/opensergo/OpenSergoClientSubscribeInfo.java diff --git a/src/main/java/io/opensergo/OpenSergoClient.java b/src/main/java/io/opensergo/OpenSergoClient.java index df04edb..42054d3 100644 --- a/src/main/java/io/opensergo/OpenSergoClient.java +++ b/src/main/java/io/opensergo/OpenSergoClient.java @@ -62,20 +62,6 @@ public OpenSergoClient(String host, int port) { status = OpenSergoClientStatus.INITIAL; } - public void registerSubscribeInfo(OpenSergoClientSubscribeInfo subscribeInfo) { - // Register subscriber to local. - if (Optional.of(subscribeInfo.getSubscriberList()).isPresent() && subscribeInfo.getSubscriberList().size() > 0) { - subscribeInfo.getSubscriberList().forEach(subscriber -> { - this.subscribeRegistry.registerSubscriber(subscribeInfo.getSubscribeKey(), subscriber); - OpenSergoLogger.info("OpenSergo subscribeinfo registered, subscribeKey={}, subscriber={}", subscribeInfo.getSubscribeKey(), subscriber); - - if (requestAndResponseWriter != null && this.status == OpenSergoClientStatus.STARTED) { - this.subscribeConfig(subscribeInfo.getSubscribeKey()); - } - }); - } - } - public void start() throws Exception { OpenSergoLogger.info("OpensergoClient is starting..."); @@ -188,6 +174,13 @@ public boolean subscribeConfig(SubscribeKey subscribeKey, OpenSergoConfigSubscri // Send SubscribeRequest requestAndResponseWriter.onNext(request); + // Register subscriber to local. + if (subscriber != null) { + subscribeRegistry.registerSubscriber(subscribeKey, subscriber); + OpenSergoLogger.info("OpenSergo config subscriber registered, subscribeKey={}, subscriber={}", + subscribeKey, subscriber); + } + return true; } diff --git a/src/main/java/io/opensergo/OpenSergoClientSubscribeInfo.java b/src/main/java/io/opensergo/OpenSergoClientSubscribeInfo.java deleted file mode 100644 index 5447fd1..0000000 --- a/src/main/java/io/opensergo/OpenSergoClientSubscribeInfo.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2022, OpenSergo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.opensergo; - -import com.google.common.collect.Lists; -import io.opensergo.subscribe.OpenSergoConfigSubscriber; -import io.opensergo.subscribe.SubscribeKey; - -import java.util.List; - -/** - * @author Jiangnan Jia - **/ -public class OpenSergoClientSubscribeInfo { - - private SubscribeKey subscribeKey; - private List subscriberList; - - public OpenSergoClientSubscribeInfo(SubscribeKey subscribeKey) { - this.subscribeKey = subscribeKey; - this.subscriberList = Lists.newArrayList(); - } - public OpenSergoClientSubscribeInfo(SubscribeKey subscribeKey, List subscriberList) { - this.subscribeKey = subscribeKey; - this.subscriberList = subscriberList; - } - - public OpenSergoClientSubscribeInfo addSubscriber(OpenSergoConfigSubscriber subscriber) { - // TODO distinct the same OpenSergoConfigSubscriber - this.subscriberList.add(subscriber); - return this; - } - - public SubscribeKey getSubscribeKey() { - return subscribeKey; - } - - public List getSubscriberList() { - return subscriberList; - } - - @Override - public String toString() { - return "OpensergoClientSubscribeInfo{" + - "subscribeKey=" + subscribeKey + - ", subscriberList=" + subscriberList + - '}'; - } -}