ddm-plugin-dubbo-support 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.js +111 -69
- package/dist/renderer.js +125 -100
- package/docs/images/addProject.png +0 -0
- package/docs/images/connectDubboAdmin.png +0 -0
- package/docs/images/projectPage.png +0 -0
- package/docs/images/telnet.png +0 -0
- package/package.json +29 -29
package/README.md
CHANGED
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
|
|
12
12
|
**服务测试**:服务测试(目前已支持Telnet、dubbo、http 等协议)、 `invoke` 命令生成、参数填充、响应对比
|
|
13
13
|
|
|
14
|
-

|
|
15
15
|
|
|
16
|
-

|
|
17
17
|
|
|
18
|
-

|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
# 常见问题
|
|
22
22
|
### 如何连接到dubbo-admin?
|
|
23
23
|
1. 打开dubbo-admin并且打开F12
|
|
24
24
|
2. 从控制台找到一个发往后台的请求地址,拿到它的前缀
|
|
25
|
-

|
|
26
26
|
3. 新建连接,选择dubbo-admin
|
|
27
|
-

|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
package/dist/index.js
CHANGED
|
@@ -211,9 +211,7 @@ class ZookeeperDataSource {
|
|
|
211
211
|
const exculdeName = ["mapping", "config", "metadata"];
|
|
212
212
|
const serviceList = children.filter(e => !exculdeName.find(name => name === e)).map(e => {
|
|
213
213
|
return {
|
|
214
|
-
serviceName: e
|
|
215
|
-
uniqueServiceName: e,
|
|
216
|
-
type: 'dubbo'
|
|
214
|
+
serviceName: e
|
|
217
215
|
};
|
|
218
216
|
});
|
|
219
217
|
logger__WEBPACK_IMPORTED_MODULE_6___default().info(`【接口模式】-查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
@@ -286,7 +284,6 @@ class ZookeeperDataSource {
|
|
|
286
284
|
serviceList.push({
|
|
287
285
|
application,
|
|
288
286
|
serviceName: service.name,
|
|
289
|
-
uniqueServiceName: service.name,
|
|
290
287
|
type: 'dubbo'
|
|
291
288
|
});
|
|
292
289
|
});
|
|
@@ -317,7 +314,6 @@ class ZookeeperDataSource {
|
|
|
317
314
|
serviceList.push({
|
|
318
315
|
application,
|
|
319
316
|
serviceName,
|
|
320
|
-
uniqueServiceName: serviceName,
|
|
321
317
|
discoverMode: 'mapping'
|
|
322
318
|
});
|
|
323
319
|
});
|
|
@@ -444,7 +440,6 @@ class ZookeeperDataSource {
|
|
|
444
440
|
protocol: applicationMetadata.protocol,
|
|
445
441
|
application: instanceData.name,
|
|
446
442
|
serviceName: serviceInfo.serviceName,
|
|
447
|
-
uniqueServiceName: serviceInfo.uniqueServiceName || serviceInfo.serviceName,
|
|
448
443
|
version: applicationMetadata.version || metadataParams?.version || '',
|
|
449
444
|
methods: Array.from(new Set((metadataParams.methods || "").split(",").filter(Boolean))),
|
|
450
445
|
revision: metadataParams.revision,
|
|
@@ -614,7 +609,6 @@ class ZookeeperDataSource {
|
|
|
614
609
|
address: `${urlData.host}:${urlData.port}`,
|
|
615
610
|
application: urlData.params.application,
|
|
616
611
|
serviceName: urlData.params.interface,
|
|
617
|
-
uniqueServiceName: urlData.params.interface,
|
|
618
612
|
version: urlData.params.version,
|
|
619
613
|
weight: urlData.params.weight,
|
|
620
614
|
// 是否过时
|
|
@@ -49870,7 +49864,7 @@ class NacosDataSource {
|
|
|
49870
49864
|
// let url = `${dataSourceInfo.address}/nacos/v1/ns/instance/list`;
|
|
49871
49865
|
|
|
49872
49866
|
// let params = {
|
|
49873
|
-
// serviceName:
|
|
49867
|
+
// serviceName: xxx,
|
|
49874
49868
|
// namespaceId: dataSourceInfo.namespaceId || "",
|
|
49875
49869
|
// groupName: dataSourceInfo.groupName || "",
|
|
49876
49870
|
// accessToken: await this.getAccessToken(dataSourceInfo)
|
|
@@ -52858,11 +52852,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
52858
52852
|
/* harmony export */ });
|
|
52859
52853
|
/* harmony import */ var logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
|
|
52860
52854
|
/* harmony import */ var logger__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(logger__WEBPACK_IMPORTED_MODULE_0__);
|
|
52861
|
-
/* harmony import */ var
|
|
52862
|
-
/* harmony import */ var
|
|
52863
|
-
/* harmony import */ var
|
|
52864
|
-
/* harmony import */ var
|
|
52865
|
-
/* harmony import */ var
|
|
52855
|
+
/* harmony import */ var appConfig__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(362);
|
|
52856
|
+
/* harmony import */ var appConfig__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(appConfig__WEBPACK_IMPORTED_MODULE_1__);
|
|
52857
|
+
/* harmony import */ var _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
|
|
52858
|
+
/* harmony import */ var _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(398);
|
|
52859
|
+
/* harmony import */ var _main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(202);
|
|
52860
|
+
/* harmony import */ var _main_generator_ParamGeneratorAdapter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(203);
|
|
52861
|
+
/* harmony import */ var _main_invoker___WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(346);
|
|
52862
|
+
|
|
52866
52863
|
|
|
52867
52864
|
|
|
52868
52865
|
|
|
@@ -52876,35 +52873,38 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
52876
52873
|
*/
|
|
52877
52874
|
class Nacos3DataSource {
|
|
52878
52875
|
async getServiceList(dataSourceInfo) {
|
|
52879
|
-
const
|
|
52880
|
-
const
|
|
52876
|
+
const nacosServiceList = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getNacosServiceList(dataSourceInfo);
|
|
52877
|
+
const applicationServiceList = dataSourceInfo.instanceMode !== false ? await this.getApplicationServiceList(dataSourceInfo, nacosServiceList) : [];
|
|
52878
|
+
const interfaceServiceList = dataSourceInfo.interfaceMode !== false ? await this.getInterfaceServiceList(dataSourceInfo, nacosServiceList) : [];
|
|
52881
52879
|
return {
|
|
52882
52880
|
list: this.mergeServiceList(interfaceServiceList, applicationServiceList),
|
|
52883
52881
|
separator: '.',
|
|
52884
52882
|
packageSeparator: '.'
|
|
52885
52883
|
};
|
|
52886
52884
|
}
|
|
52887
|
-
async getApplicationServiceList(dataSourceInfo) {
|
|
52885
|
+
async getApplicationServiceList(dataSourceInfo, nacosServiceList) {
|
|
52888
52886
|
const serviceList = [];
|
|
52889
52887
|
let startTime = Date.now();
|
|
52890
52888
|
try {
|
|
52891
|
-
serviceList.push(...(await this.getServiceListByApplicationMatedata(dataSourceInfo)));
|
|
52892
|
-
logger__WEBPACK_IMPORTED_MODULE_0___default().info(
|
|
52889
|
+
serviceList.push(...(await this.getServiceListByApplicationMatedata(dataSourceInfo, nacosServiceList)));
|
|
52890
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().info(`[ Nacos3 应用模式 ] 查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
52893
52891
|
} catch (e) {
|
|
52894
|
-
logger__WEBPACK_IMPORTED_MODULE_0___default().error(
|
|
52892
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().error(`[ Nacos3 应用模式 ] 查询服务列表 失败 耗时:${Date.now() - startTime}ms`, e);
|
|
52895
52893
|
}
|
|
52896
|
-
|
|
52897
|
-
|
|
52898
|
-
|
|
52899
|
-
|
|
52900
|
-
|
|
52901
|
-
|
|
52894
|
+
if (dataSourceInfo.useApplicationMapping === true) {
|
|
52895
|
+
startTime = Date.now();
|
|
52896
|
+
try {
|
|
52897
|
+
serviceList.push(...(await this.getServiceListByMapping(dataSourceInfo, new Set(serviceList.map(item => item.serviceName)))));
|
|
52898
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().info(`[ Nacos3 应用模式-兜底反推 ] 查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
52899
|
+
} catch (e) {
|
|
52900
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().error(`[ Nacos3 应用模式-兜底反推 ] 查询服务列表 失败 耗时:${Date.now() - startTime}ms`, e);
|
|
52901
|
+
}
|
|
52902
52902
|
}
|
|
52903
52903
|
return serviceList;
|
|
52904
52904
|
}
|
|
52905
|
-
async getServiceListByApplicationMatedata(dataSourceInfo) {
|
|
52905
|
+
async getServiceListByApplicationMatedata(dataSourceInfo, nacosServiceList) {
|
|
52906
52906
|
const serviceList = [];
|
|
52907
|
-
for (const application of await this.getAppNameList(dataSourceInfo)) {
|
|
52907
|
+
for (const application of await this.getAppNameList(dataSourceInfo, nacosServiceList)) {
|
|
52908
52908
|
const cache = new Set();
|
|
52909
52909
|
for (const instance of await this.getAppInstanceList(dataSourceInfo, application)) {
|
|
52910
52910
|
const revision = this.getMetadataRevision(instance);
|
|
@@ -52936,17 +52936,16 @@ class Nacos3DataSource {
|
|
|
52936
52936
|
return serviceList;
|
|
52937
52937
|
}
|
|
52938
52938
|
async getServiceListByMapping(dataSourceInfo, excludeServiceNameSet) {
|
|
52939
|
-
const configList = await
|
|
52939
|
+
const configList = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getConfigList(dataSourceInfo, "", "mapping");
|
|
52940
52940
|
return configList.filter(config => !excludeServiceNameSet.has(config.dataId)).map(config => ({
|
|
52941
52941
|
application: config.content,
|
|
52942
52942
|
serviceName: config.dataId,
|
|
52943
52943
|
discoverMode: 'mapping'
|
|
52944
52944
|
}));
|
|
52945
52945
|
}
|
|
52946
|
-
async getInterfaceServiceList(dataSourceInfo) {
|
|
52947
|
-
const serviceNameList = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_2__["default"].getNacosServiceList(dataSourceInfo);
|
|
52946
|
+
async getInterfaceServiceList(dataSourceInfo, nacosServiceList) {
|
|
52948
52947
|
const serviceList = new Set();
|
|
52949
|
-
for (const serviceName of
|
|
52948
|
+
for (const serviceName of nacosServiceList) {
|
|
52950
52949
|
const datas = serviceName.split(":");
|
|
52951
52950
|
if (datas[0] !== "providers") {
|
|
52952
52951
|
continue;
|
|
@@ -52970,9 +52969,15 @@ class Nacos3DataSource {
|
|
|
52970
52969
|
}
|
|
52971
52970
|
async getProviderList(dataSourceInfo, serviceInfo) {
|
|
52972
52971
|
if (serviceInfo.application && serviceInfo.discoverMode !== 'mapping') {
|
|
52972
|
+
if (appConfig__WEBPACK_IMPORTED_MODULE_1___default().getPluginProperty('logEnable') === true) {
|
|
52973
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().info(`查询提供者 应用模式查询提供者 serviceName:${serviceInfo.serviceName}`);
|
|
52974
|
+
}
|
|
52973
52975
|
return await this.getApplicationProviderList(dataSourceInfo, serviceInfo);
|
|
52974
52976
|
}
|
|
52975
|
-
|
|
52977
|
+
if (appConfig__WEBPACK_IMPORTED_MODULE_1___default().getPluginProperty('logEnable') === true) {
|
|
52978
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().info(`查询提供者 接口模式 serviceName:${serviceInfo.serviceName}`);
|
|
52979
|
+
}
|
|
52980
|
+
const providerNameList = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getProviderNameList(dataSourceInfo, serviceInfo.serviceName);
|
|
52976
52981
|
if (serviceInfo.discoverMode === 'mapping' && providerNameList.length === 0) {
|
|
52977
52982
|
throw new Error(`你当前接口是dubbo3应用模式,需要开启配置[dubbo.application.metadata-type=remote]才能获取到提供者列表`);
|
|
52978
52983
|
}
|
|
@@ -52980,14 +52985,14 @@ class Nacos3DataSource {
|
|
|
52980
52985
|
for (const providerName of providerNameList) {
|
|
52981
52986
|
const serviceDisabledMap = new Map();
|
|
52982
52987
|
const serviceMetadataMap = new Map();
|
|
52983
|
-
const instanceList = await
|
|
52988
|
+
const instanceList = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getInstanceList(dataSourceInfo, providerName);
|
|
52984
52989
|
if (instanceList.length === 0) {
|
|
52985
52990
|
continue;
|
|
52986
52991
|
}
|
|
52987
52992
|
for (const instance of instanceList) {
|
|
52988
52993
|
let providerInfo = this.parseProvderInfo(instance);
|
|
52989
52994
|
const disabledAddresses = await serviceDisabledMap.computeIfAbsent(this.buildDataId(providerInfo), async () => {
|
|
52990
|
-
return
|
|
52995
|
+
return _main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_4__["default"].getDisableAddresses(await this.getJsonConfiguration(dataSourceInfo, serviceInfo, providerInfo));
|
|
52991
52996
|
});
|
|
52992
52997
|
providerInfo.disabled = disabledAddresses.find(item => item === '0.0.0.0' || item === providerInfo.address) != null;
|
|
52993
52998
|
const key = `${providerInfo.application}-${providerInfo.serviceName}-${providerInfo.version}-${providerInfo.group}`;
|
|
@@ -53003,16 +53008,16 @@ class Nacos3DataSource {
|
|
|
53003
53008
|
application,
|
|
53004
53009
|
serviceName
|
|
53005
53010
|
} = serviceInfo;
|
|
53011
|
+
const startTime = Date.now();
|
|
53006
53012
|
const providerList = [];
|
|
53007
53013
|
const cache = new Map();
|
|
53008
|
-
const
|
|
53009
|
-
for (const instance of instanceList) {
|
|
53014
|
+
for (const instance of await this.getAppInstanceList(dataSourceInfo, application)) {
|
|
53010
53015
|
const revision = this.getMetadataRevision(instance);
|
|
53011
53016
|
if (!revision) {
|
|
53012
53017
|
continue;
|
|
53013
53018
|
}
|
|
53014
53019
|
const appMetadata = await cache.computeIfAbsent(`a-${revision}`, () => this.getAppMetadata(dataSourceInfo, application, revision));
|
|
53015
|
-
if (!appMetadata
|
|
53020
|
+
if (!appMetadata?.services) {
|
|
53016
53021
|
continue;
|
|
53017
53022
|
}
|
|
53018
53023
|
const appServiceMetadatas = Object.values(appMetadata.services).filter(service => {
|
|
@@ -53027,6 +53032,9 @@ class Nacos3DataSource {
|
|
|
53027
53032
|
providerList.push(providerInfo);
|
|
53028
53033
|
}
|
|
53029
53034
|
}
|
|
53035
|
+
if (appConfig__WEBPACK_IMPORTED_MODULE_1___default().getPluginProperty('logEnable') === true) {
|
|
53036
|
+
logger__WEBPACK_IMPORTED_MODULE_0___default().info(`[ Nacos3Utils ] 查询到提供者列表 params:${serviceName}, 提供者数量:${providerList.length}, 耗时:${Date.now() - startTime}ms`);
|
|
53037
|
+
}
|
|
53030
53038
|
return providerList;
|
|
53031
53039
|
}
|
|
53032
53040
|
resolveMethodList(methods, metadata) {
|
|
@@ -53035,7 +53043,7 @@ class Nacos3DataSource {
|
|
|
53035
53043
|
...method,
|
|
53036
53044
|
name: `${method.name}(${method.parameterTypes.map(pp => pp.substring(pp.lastIndexOf(".") + 1))})`,
|
|
53037
53045
|
methodName: method.name,
|
|
53038
|
-
defaultParameter: JSON.stringify(
|
|
53046
|
+
defaultParameter: JSON.stringify(_main_generator_ParamGeneratorAdapter__WEBPACK_IMPORTED_MODULE_5__["default"].generateParam(metadata, method.name), null, 2) || "[]"
|
|
53039
53047
|
}));
|
|
53040
53048
|
}
|
|
53041
53049
|
return methods.map(method => ({
|
|
@@ -53072,31 +53080,31 @@ class Nacos3DataSource {
|
|
|
53072
53080
|
}
|
|
53073
53081
|
async disableProvider(dataSourceInfo, serviceInfo, providerInfo) {
|
|
53074
53082
|
let doc = await this.getJsonConfiguration(dataSourceInfo, serviceInfo, providerInfo);
|
|
53075
|
-
doc = await
|
|
53083
|
+
doc = await _main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_4__["default"].addDisableProvider(doc, providerInfo.address);
|
|
53076
53084
|
await this.doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo, doc);
|
|
53077
53085
|
}
|
|
53078
53086
|
async enableProvider(dataSourceInfo, serviceInfo, providerInfo) {
|
|
53079
53087
|
let doc = await this.getJsonConfiguration(dataSourceInfo, serviceInfo, providerInfo);
|
|
53080
|
-
doc = await
|
|
53088
|
+
doc = await _main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_4__["default"].removeDisableProvider(doc, providerInfo.address);
|
|
53081
53089
|
await this.doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo, doc);
|
|
53082
53090
|
}
|
|
53083
53091
|
async getConfiguration(dataSourceInfo, serviceInfo, providerInfo) {
|
|
53084
|
-
const config = await
|
|
53085
|
-
return config ? config :
|
|
53092
|
+
const config = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getConfig(dataSourceInfo, this.buildDataId(providerInfo), dataSourceInfo.group || 'dubbo');
|
|
53093
|
+
return config ? config : _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_2__["default"].JSONToYaml(_main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_4__["default"].createDubboDefaultConfiguration());
|
|
53086
53094
|
}
|
|
53087
53095
|
async getJsonConfiguration(dataSourceInfo, serviceInfo, providerInfo) {
|
|
53088
|
-
return
|
|
53096
|
+
return _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_2__["default"].yamlToJSON(await this.getConfiguration(dataSourceInfo, serviceInfo, providerInfo));
|
|
53089
53097
|
}
|
|
53090
53098
|
async saveConfiguration(dataSourceInfo, serviceInfo, providerInfo, ymal) {
|
|
53091
|
-
await this.doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo,
|
|
53099
|
+
await this.doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo, _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_2__["default"].yamlToJSON(ymal));
|
|
53092
53100
|
}
|
|
53093
53101
|
async doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo, doc) {
|
|
53094
53102
|
const dataId = this.buildDataId(providerInfo);
|
|
53095
|
-
const config = doc?.configs?.length > 0 ?
|
|
53096
|
-
await
|
|
53103
|
+
const config = doc?.configs?.length > 0 ? _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_2__["default"].JSONToYaml(doc) : null;
|
|
53104
|
+
await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].saveConfig(dataSourceInfo, dataId, dataSourceInfo.group || 'dubbo', config);
|
|
53097
53105
|
}
|
|
53098
53106
|
async invokeMethod(dataSourceInfo, serviceInfo, provder, methodInfo, code, invokerType) {
|
|
53099
|
-
return
|
|
53107
|
+
return _main_invoker___WEBPACK_IMPORTED_MODULE_6__["default"].invokeMethod(provder, methodInfo, code, invokerType);
|
|
53100
53108
|
}
|
|
53101
53109
|
buildDataId({
|
|
53102
53110
|
serviceName,
|
|
@@ -53145,9 +53153,11 @@ class Nacos3DataSource {
|
|
|
53145
53153
|
qosPort: data.qosPort || data.port
|
|
53146
53154
|
};
|
|
53147
53155
|
}
|
|
53148
|
-
async getAppNameList(dataSourceInfo) {
|
|
53149
|
-
|
|
53150
|
-
|
|
53156
|
+
async getAppNameList(dataSourceInfo, nacosServiceList) {
|
|
53157
|
+
// 使用共享的服务列表
|
|
53158
|
+
// const serviceList = await nacos3Utils.getNacosServiceList(dataSourceInfo);
|
|
53159
|
+
|
|
53160
|
+
return nacosServiceList.filter(serviceName => {
|
|
53151
53161
|
const datas = serviceName.split(":");
|
|
53152
53162
|
if (datas[0] === "providers" || datas[0] === "consumers") {
|
|
53153
53163
|
return false;
|
|
@@ -53156,7 +53166,7 @@ class Nacos3DataSource {
|
|
|
53156
53166
|
});
|
|
53157
53167
|
}
|
|
53158
53168
|
async getAppInstanceList(dataSourceInfo, application) {
|
|
53159
|
-
return await
|
|
53169
|
+
return await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getInstanceList(dataSourceInfo, application);
|
|
53160
53170
|
}
|
|
53161
53171
|
async getAppMetadata(dataSourceInfo, application, revision) {
|
|
53162
53172
|
return (await this.getJsonConfig(dataSourceInfo, application, revision)) || {};
|
|
@@ -53166,7 +53176,7 @@ class Nacos3DataSource {
|
|
|
53166
53176
|
return (await this.getJsonConfig(dataSourceInfo, dataId, dataSourceInfo.group || 'dubbo')) || {};
|
|
53167
53177
|
}
|
|
53168
53178
|
async getJsonConfig(dataSourceInfo, dataId, groupName) {
|
|
53169
|
-
const config = await
|
|
53179
|
+
const config = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_3__["default"].getConfig(dataSourceInfo, dataId, groupName);
|
|
53170
53180
|
if (!config) {
|
|
53171
53181
|
return null;
|
|
53172
53182
|
}
|
|
@@ -53197,8 +53207,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
53197
53207
|
/* harmony export */ });
|
|
53198
53208
|
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
|
|
53199
53209
|
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
|
|
53200
|
-
/* harmony import */ var
|
|
53201
|
-
/* harmony import */ var
|
|
53210
|
+
/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(368);
|
|
53211
|
+
/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_3__);
|
|
53212
|
+
/* harmony import */ var logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
|
|
53213
|
+
/* harmony import */ var logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(logger__WEBPACK_IMPORTED_MODULE_1__);
|
|
53214
|
+
/* harmony import */ var appConfig__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(362);
|
|
53215
|
+
/* harmony import */ var appConfig__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(appConfig__WEBPACK_IMPORTED_MODULE_2__);
|
|
53216
|
+
|
|
53217
|
+
|
|
53202
53218
|
|
|
53203
53219
|
|
|
53204
53220
|
class Nacos3Utils {
|
|
@@ -53215,7 +53231,11 @@ class Nacos3Utils {
|
|
|
53215
53231
|
withInstances: false,
|
|
53216
53232
|
accessToken: await this.getAccessToken(dataSourceInfo)
|
|
53217
53233
|
};
|
|
53234
|
+
let queryCount = 0;
|
|
53235
|
+
let queryServiceCount = 0;
|
|
53236
|
+
const startTime = Date.now();
|
|
53218
53237
|
do {
|
|
53238
|
+
queryCount++;
|
|
53219
53239
|
const {
|
|
53220
53240
|
data
|
|
53221
53241
|
} = await axios__WEBPACK_IMPORTED_MODULE_0___default().get(url, {
|
|
@@ -53227,11 +53247,15 @@ class Nacos3Utils {
|
|
|
53227
53247
|
serviceList.push(item.name);
|
|
53228
53248
|
}
|
|
53229
53249
|
});
|
|
53250
|
+
queryServiceCount += pageItems.length;
|
|
53230
53251
|
if (pageItems.length < params.pageSize) {
|
|
53231
53252
|
break;
|
|
53232
53253
|
}
|
|
53233
53254
|
params.pageNo++;
|
|
53234
53255
|
} while (true);
|
|
53256
|
+
if (appConfig__WEBPACK_IMPORTED_MODULE_2___default().getPluginProperty('logEnable') === true) {
|
|
53257
|
+
logger__WEBPACK_IMPORTED_MODULE_1___default().info(`[ Nacos3Utils ] -查询Nacos服务列表 queryCount:${queryCount}, queryServiceCount:${queryServiceCount}, 实际接口数:${serviceList.length}, 耗时:${Date.now() - startTime}ms`);
|
|
53258
|
+
}
|
|
53235
53259
|
return serviceList;
|
|
53236
53260
|
}
|
|
53237
53261
|
async getProviderNameList(dataSourceInfo, serviceName = '*') {
|
|
@@ -53247,7 +53271,11 @@ class Nacos3Utils {
|
|
|
53247
53271
|
withInstances: false,
|
|
53248
53272
|
accessToken: await this.getAccessToken(dataSourceInfo)
|
|
53249
53273
|
};
|
|
53274
|
+
let queryCount = 0;
|
|
53275
|
+
let queryServiceCount = 0;
|
|
53276
|
+
const startTime = Date.now();
|
|
53250
53277
|
do {
|
|
53278
|
+
queryCount++;
|
|
53251
53279
|
const {
|
|
53252
53280
|
data
|
|
53253
53281
|
} = await axios__WEBPACK_IMPORTED_MODULE_0___default().get(url, {
|
|
@@ -53259,11 +53287,15 @@ class Nacos3Utils {
|
|
|
53259
53287
|
providerNameList.push(item.name);
|
|
53260
53288
|
}
|
|
53261
53289
|
});
|
|
53290
|
+
queryServiceCount += pageItems.length;
|
|
53262
53291
|
if (pageItems.length < params.pageSize) {
|
|
53263
53292
|
break;
|
|
53264
53293
|
}
|
|
53265
53294
|
params.pageNo++;
|
|
53266
53295
|
} while (true);
|
|
53296
|
+
if (appConfig__WEBPACK_IMPORTED_MODULE_2___default().getPluginProperty('logEnable') === true) {
|
|
53297
|
+
logger__WEBPACK_IMPORTED_MODULE_1___default().info(`[ Nacos3Utils ] 查询到提供者列表 serviceName:${serviceName}, queryCount:${queryCount}, queryServiceCount:${queryServiceCount}, 实际提供者数:${providerNameList.length}, 耗时:${Date.now() - startTime}ms`);
|
|
53298
|
+
}
|
|
53267
53299
|
return providerNameList;
|
|
53268
53300
|
}
|
|
53269
53301
|
async getInstanceList(dataSourceInfo, serviceName) {
|
|
@@ -53292,6 +53324,14 @@ class Nacos3Utils {
|
|
|
53292
53324
|
} while (true);
|
|
53293
53325
|
return result;
|
|
53294
53326
|
}
|
|
53327
|
+
|
|
53328
|
+
/**
|
|
53329
|
+
* 这个接口性能很差,慎用,nacos1、2会直接返回content,但是nacos3不会,只能一个个去查了,所以性能很差
|
|
53330
|
+
* @param {*} dataSourceInfo
|
|
53331
|
+
* @param {*} dataId
|
|
53332
|
+
* @param {*} groupName
|
|
53333
|
+
* @returns
|
|
53334
|
+
*/
|
|
53295
53335
|
async getConfigList(dataSourceInfo, dataId, groupName) {
|
|
53296
53336
|
const url = `${dataSourceInfo.address}/v3/console/cs/config/list`;
|
|
53297
53337
|
const params = {
|
|
@@ -53307,7 +53347,11 @@ class Nacos3Utils {
|
|
|
53307
53347
|
accessToken: await this.getAccessToken(dataSourceInfo)
|
|
53308
53348
|
};
|
|
53309
53349
|
const result = [];
|
|
53350
|
+
let queryCount = 0;
|
|
53351
|
+
let queryConfigCount = 0;
|
|
53352
|
+
const startTime = Date.now();
|
|
53310
53353
|
do {
|
|
53354
|
+
queryCount++;
|
|
53311
53355
|
const {
|
|
53312
53356
|
data
|
|
53313
53357
|
} = await axios__WEBPACK_IMPORTED_MODULE_0___default().get(url, {
|
|
@@ -53316,21 +53360,26 @@ class Nacos3Utils {
|
|
|
53316
53360
|
const pageItems = data?.data?.pageItems || [];
|
|
53317
53361
|
for (let i = 0; i < pageItems.length; i++) {
|
|
53318
53362
|
const item = pageItems[i];
|
|
53319
|
-
if (item.content) {
|
|
53320
|
-
|
|
53321
|
-
|
|
53322
|
-
}
|
|
53363
|
+
// if (item.content) {
|
|
53364
|
+
// result.push(item);
|
|
53365
|
+
// continue;
|
|
53366
|
+
// }
|
|
53367
|
+
|
|
53323
53368
|
const content = await this.getConfig(dataSourceInfo, item.dataId, groupName);
|
|
53324
53369
|
result.push({
|
|
53325
53370
|
...item,
|
|
53326
53371
|
content
|
|
53327
53372
|
});
|
|
53328
53373
|
}
|
|
53374
|
+
queryConfigCount += pageItems.length;
|
|
53329
53375
|
if (pageItems.length < params.pageSize) {
|
|
53330
53376
|
break;
|
|
53331
53377
|
}
|
|
53332
53378
|
params.pageNo++;
|
|
53333
53379
|
} while (true);
|
|
53380
|
+
if (appConfig__WEBPACK_IMPORTED_MODULE_2___default().getPluginProperty('logEnable') === true) {
|
|
53381
|
+
logger__WEBPACK_IMPORTED_MODULE_1___default().info(`[ Nacos3Utils ] 查询到提供者列表 dataId:${dataId}, group:${groupName}, queryCount:${queryCount}, queryConfigCount:${queryConfigCount}, 实际配置数:${result.length}, 耗时:${Date.now() - startTime}ms`);
|
|
53382
|
+
}
|
|
53334
53383
|
return result;
|
|
53335
53384
|
}
|
|
53336
53385
|
async getConfig(dataSourceInfo, dataId, groupName) {
|
|
@@ -53366,7 +53415,7 @@ class Nacos3Utils {
|
|
|
53366
53415
|
if (config) {
|
|
53367
53416
|
params.content = config;
|
|
53368
53417
|
params.type = 'yaml';
|
|
53369
|
-
await axios__WEBPACK_IMPORTED_MODULE_0___default().post(url,
|
|
53418
|
+
await axios__WEBPACK_IMPORTED_MODULE_0___default().post(url, qs__WEBPACK_IMPORTED_MODULE_3___default().stringify(params));
|
|
53370
53419
|
} else {
|
|
53371
53420
|
await axios__WEBPACK_IMPORTED_MODULE_0___default()["delete"](url, {
|
|
53372
53421
|
params
|
|
@@ -53384,7 +53433,7 @@ class Nacos3Utils {
|
|
|
53384
53433
|
const url = `${dataSourceInfo.address}/v3/auth/user/login`;
|
|
53385
53434
|
const {
|
|
53386
53435
|
data
|
|
53387
|
-
} = await axios__WEBPACK_IMPORTED_MODULE_0___default().post(url,
|
|
53436
|
+
} = await axios__WEBPACK_IMPORTED_MODULE_0___default().post(url, qs__WEBPACK_IMPORTED_MODULE_3___default().stringify(params));
|
|
53388
53437
|
return data?.accessToken;
|
|
53389
53438
|
}
|
|
53390
53439
|
unwrap(response) {
|
|
@@ -53443,9 +53492,7 @@ class EtcdDataSource {
|
|
|
53443
53492
|
const exculdeName = ["mapping", "config", "metadata"];
|
|
53444
53493
|
const serviceList = children.filter(e => !exculdeName.find(name => name == e)).map(e => {
|
|
53445
53494
|
return {
|
|
53446
|
-
serviceName: e
|
|
53447
|
-
uniqueServiceName: e,
|
|
53448
|
-
type: 'dubbo'
|
|
53495
|
+
serviceName: e
|
|
53449
53496
|
};
|
|
53450
53497
|
});
|
|
53451
53498
|
logger__WEBPACK_IMPORTED_MODULE_5___default().info(`【etcd接口模式】-查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
@@ -53497,9 +53544,7 @@ class EtcdDataSource {
|
|
|
53497
53544
|
cache.add(primaryKey);
|
|
53498
53545
|
serviceList.push({
|
|
53499
53546
|
application,
|
|
53500
|
-
serviceName
|
|
53501
|
-
uniqueServiceName: serviceName,
|
|
53502
|
-
type: 'dubbo'
|
|
53547
|
+
serviceName
|
|
53503
53548
|
});
|
|
53504
53549
|
});
|
|
53505
53550
|
}
|
|
@@ -53519,7 +53564,6 @@ class EtcdDataSource {
|
|
|
53519
53564
|
serviceList.push({
|
|
53520
53565
|
application,
|
|
53521
53566
|
serviceName,
|
|
53522
|
-
uniqueServiceName: serviceName,
|
|
53523
53567
|
discoverMode: 'mapping'
|
|
53524
53568
|
});
|
|
53525
53569
|
});
|
|
@@ -53623,7 +53667,6 @@ class EtcdDataSource {
|
|
|
53623
53667
|
protocol: applicationMetadata.protocol,
|
|
53624
53668
|
application: serviceInfo.application,
|
|
53625
53669
|
serviceName: serviceInfo.serviceName,
|
|
53626
|
-
uniqueServiceName: serviceInfo.uniqueServiceName || serviceInfo.serviceName,
|
|
53627
53670
|
version: applicationMetadata.version || metadataParams?.version || '',
|
|
53628
53671
|
group: applicationMetadata.group || metadataParams?.group || '',
|
|
53629
53672
|
methods: Array.from(new Set((metadataParams.methods || "").split(",").filter(Boolean))),
|
|
@@ -53707,7 +53750,6 @@ class EtcdDataSource {
|
|
|
53707
53750
|
port: urlData.port,
|
|
53708
53751
|
address: `${urlData.host}:${urlData.port}`,
|
|
53709
53752
|
serviceName: urlData.params.interface,
|
|
53710
|
-
uniqueServiceName: urlData.params.interface,
|
|
53711
53753
|
version: urlData.params.version,
|
|
53712
53754
|
group: urlData.params.group,
|
|
53713
53755
|
weight: urlData.params.weight,
|