nacos-client 推送和移除配置源码

String url = Constants.CONFIG_CONTROLLER_PATH;
        Map params = new HashMap(6);
        params.put("dataId", dataId);
        params.put("group", group);
        params.put("content", content);
        params.put("type", type);
        if (StringUtils.isNotEmpty(tenant)) {
            params.put("tenant", tenant);
        }
        if (StringUtils.isNotEmpty(appName)) {
            params.put("appName", appName);
        }
        if (StringUtils.isNotEmpty(tag)) {
            params.put("tag", tag);
        }
        Map headers = new HashMap(1);
        if (StringUtils.isNotEmpty(betaIps)) {
            headers.put("betaIps", betaIps);
        }
        
        HttpRestResult result = null;
        try {
            result = agent.httpPost(url, headers, params, encode, POST_TIMEOUT);
        } catch (Exception ex) {
            LOGGER.warn("[{}] [publish-single] exception, dataId={}, group={}, msg={}", agent.getName(), dataId, group,
                    ex.toString());
            return false;
        }
推送配置源码:com.alibaba.nacos.client.config.NacosConfigService#publishConfigInner

移除配置:com.alibaba.nacos.client.config.NacosConfigService#removeConfig

String url = Constants.CONFIG_CONTROLLER_PATH;
        Map params = new HashMap(4);
        params.put("dataId", dataId);
        params.put("group", group);
        
        if (StringUtils.isNotEmpty(tenant)) {
            params.put("tenant", tenant);
        }
        if (StringUtils.isNotEmpty(tag)) {
            params.put("tag", tag);
        }
        HttpRestResult result = null;
        try {
            result = agent.httpDelete(url, null, params, encode, POST_TIMEOUT);
        } catch (Exception ex) {
            LOGGER.warn("[remove] error, " + dataId + ", " + group + ", " + tenant + ", msg: " + ex.toString());
            return false;
        }
注意到了吗?nacos-client是使用restful api风格。 获取配置是get,推送配置是post,移除配置是delete

你可能感兴趣的:(Nacos一路持之以恒)