优化etcd监听节点变化实现

This commit is contained in:
zendwang
2022-11-11 20:33:20 +08:00
parent 6fed03f225
commit 4034f14843
2 changed files with 2 additions and 12 deletions

View File

@@ -57,17 +57,7 @@ public class EtcdXmlELParser extends ClassXmlFlowELParser {
try {
String content = etcdParserHelper.getContent();
Consumer<String> listenerConsumer = t -> {
try {
parse(t);
} catch (Exception e) {
throw new RuntimeException(e);
}
};
etcdParserHelper.listen(listenerConsumer);
etcdParserHelper.listen();
return content;
} catch (Exception e){
throw new EtcdException(e.getMessage());

View File

@@ -145,7 +145,7 @@ public class EtcdParserHelper {
/**
* 监听 etcd 节点
*/
public void listen(Consumer<String> parseConsumer) {
public void listen() {
this.client.watchChildChange(this.etcdParserVO.getChainPath(), (updatePath, updateValue) -> {
LOG.info("starting reload flow config... update path={} value={},", updatePath, updateValue);
String chainName = updatePath.replace(this.etcdParserVO.getChainPath() + SEPARATOR, "");