ddm-plugin-dubbo-support 0.3.0 → 0.3.2
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/dist/index.js +253 -59
- package/package.json +1 -1
- package/docs/.DS_Store +0 -0
- package/public/.DS_Store +0 -0
- package/public/jar/.DS_Store +0 -0
package/dist/index.js
CHANGED
|
@@ -49693,7 +49693,7 @@ class NacosDataSource {
|
|
|
49693
49693
|
*/
|
|
49694
49694
|
async getInterfaceServiceList(dataSourceInfo) {
|
|
49695
49695
|
const serviceNameList = await _main_datasource_nacos_NacosUtils__WEBPACK_IMPORTED_MODULE_4__["default"].getNacosServiceList(dataSourceInfo);
|
|
49696
|
-
const serviceList = new
|
|
49696
|
+
const serviceList = new Set();
|
|
49697
49697
|
for (const serviceName of serviceNameList) {
|
|
49698
49698
|
// doms的每个元素: "providers:org.apache.dubbo.demo.DemoService:1.0.0:${分组}",
|
|
49699
49699
|
const datas = serviceName.split(":");
|
|
@@ -49702,17 +49702,11 @@ class NacosDataSource {
|
|
|
49702
49702
|
if (datas[0] !== "providers") {
|
|
49703
49703
|
continue;
|
|
49704
49704
|
}
|
|
49705
|
-
|
|
49706
|
-
if (!serviceInfo) {
|
|
49707
|
-
serviceInfo = {
|
|
49708
|
-
serviceName: datas[1],
|
|
49709
|
-
providers: []
|
|
49710
|
-
};
|
|
49711
|
-
serviceList.set(datas[1], serviceInfo);
|
|
49712
|
-
}
|
|
49713
|
-
serviceInfo.providers.push(serviceName);
|
|
49705
|
+
serviceList.add(datas[1]);
|
|
49714
49706
|
}
|
|
49715
|
-
return serviceList
|
|
49707
|
+
return Array.from(serviceList).map(serviceName => {
|
|
49708
|
+
serviceName;
|
|
49709
|
+
});
|
|
49716
49710
|
}
|
|
49717
49711
|
|
|
49718
49712
|
/**
|
|
@@ -52951,23 +52945,17 @@ class Nacos3DataSource {
|
|
|
52951
52945
|
}
|
|
52952
52946
|
async getInterfaceServiceList(dataSourceInfo) {
|
|
52953
52947
|
const serviceNameList = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_2__["default"].getNacosServiceList(dataSourceInfo);
|
|
52954
|
-
const serviceList = new
|
|
52948
|
+
const serviceList = new Set();
|
|
52955
52949
|
for (const serviceName of serviceNameList) {
|
|
52956
52950
|
const datas = serviceName.split(":");
|
|
52957
52951
|
if (datas[0] !== "providers") {
|
|
52958
52952
|
continue;
|
|
52959
52953
|
}
|
|
52960
|
-
|
|
52961
|
-
if (!serviceInfo) {
|
|
52962
|
-
serviceInfo = {
|
|
52963
|
-
serviceName: datas[1],
|
|
52964
|
-
providers: []
|
|
52965
|
-
};
|
|
52966
|
-
serviceList.set(datas[1], serviceInfo);
|
|
52967
|
-
}
|
|
52968
|
-
serviceInfo.providers.push(serviceName);
|
|
52954
|
+
serviceList.add(datas[1]);
|
|
52969
52955
|
}
|
|
52970
|
-
return Array.from(serviceList.
|
|
52956
|
+
return Array.from(serviceList).map(serviceName => ({
|
|
52957
|
+
serviceName
|
|
52958
|
+
}));
|
|
52971
52959
|
}
|
|
52972
52960
|
mergeServiceList(interfaceServiceList, applicationServiceList) {
|
|
52973
52961
|
const applicationServiceNameSet = new Set(applicationServiceList.map(item => item.serviceName));
|
|
@@ -53093,7 +53081,7 @@ class Nacos3DataSource {
|
|
|
53093
53081
|
await this.doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo, doc);
|
|
53094
53082
|
}
|
|
53095
53083
|
async getConfiguration(dataSourceInfo, serviceInfo, providerInfo) {
|
|
53096
|
-
const config = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_2__["default"].getConfig(dataSourceInfo, this.buildDataId(providerInfo));
|
|
53084
|
+
const config = await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_2__["default"].getConfig(dataSourceInfo, this.buildDataId(providerInfo), dataSourceInfo.group || 'dubbo');
|
|
53097
53085
|
return config ? config : _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_1__["default"].JSONToYaml(_main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_3__["default"].createDubboDefaultConfiguration());
|
|
53098
53086
|
}
|
|
53099
53087
|
async getJsonConfiguration(dataSourceInfo, serviceInfo, providerInfo) {
|
|
@@ -53105,7 +53093,7 @@ class Nacos3DataSource {
|
|
|
53105
53093
|
async doSaveConfiguration(dataSourceInfo, serviceInfo, providerInfo, doc) {
|
|
53106
53094
|
const dataId = this.buildDataId(providerInfo);
|
|
53107
53095
|
const config = doc?.configs?.length > 0 ? _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_1__["default"].JSONToYaml(doc) : null;
|
|
53108
|
-
await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_2__["default"].saveConfig(dataSourceInfo, dataId, config);
|
|
53096
|
+
await _main_datasource_nacos3_Nacos3Utils__WEBPACK_IMPORTED_MODULE_2__["default"].saveConfig(dataSourceInfo, dataId, dataSourceInfo.group || 'dubbo', config);
|
|
53109
53097
|
}
|
|
53110
53098
|
async invokeMethod(dataSourceInfo, serviceInfo, provder, methodInfo, code, invokerType) {
|
|
53111
53099
|
return _main_invoker___WEBPACK_IMPORTED_MODULE_5__["default"].invokeMethod(provder, methodInfo, code, invokerType);
|
|
@@ -53367,11 +53355,11 @@ class Nacos3Utils {
|
|
|
53367
53355
|
throw error;
|
|
53368
53356
|
}
|
|
53369
53357
|
}
|
|
53370
|
-
async saveConfig(dataSourceInfo, dataId, config) {
|
|
53358
|
+
async saveConfig(dataSourceInfo, dataId, group, config) {
|
|
53371
53359
|
const url = `${dataSourceInfo.address}/v3/console/cs/config`;
|
|
53372
53360
|
const params = {
|
|
53373
53361
|
dataId,
|
|
53374
|
-
groupName:
|
|
53362
|
+
groupName: group,
|
|
53375
53363
|
namespaceId: dataSourceInfo.namespaceId || 'public',
|
|
53376
53364
|
accessToken: await this.getAccessToken(dataSourceInfo)
|
|
53377
53365
|
};
|
|
@@ -53419,7 +53407,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
53419
53407
|
/* harmony import */ var _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(400);
|
|
53420
53408
|
/* harmony import */ var _main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(202);
|
|
53421
53409
|
/* harmony import */ var _main_generator_ParamGeneratorAdapter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(203);
|
|
53422
|
-
/* harmony import */ var
|
|
53410
|
+
/* harmony import */ var logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
|
|
53411
|
+
/* harmony import */ var logger__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(logger__WEBPACK_IMPORTED_MODULE_5__);
|
|
53412
|
+
/* harmony import */ var _main_invoker___WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(346);
|
|
53413
|
+
|
|
53423
53414
|
|
|
53424
53415
|
|
|
53425
53416
|
|
|
@@ -53427,6 +53418,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
53427
53418
|
|
|
53428
53419
|
|
|
53429
53420
|
const PROVIDER_PREFIX = "/dubbo";
|
|
53421
|
+
const MAPPING_PREFIX = "/dubbo/mapping";
|
|
53422
|
+
const METADATA_PREFIX = "/dubbo/metadata";
|
|
53423
|
+
const APPLICATION_PREFIX = "/services";
|
|
53430
53424
|
|
|
53431
53425
|
/**
|
|
53432
53426
|
* Etcd 数据源操作类,提供 Dubbo 服务的注册、查询、配置等功能。
|
|
@@ -53435,6 +53429,16 @@ const PROVIDER_PREFIX = "/dubbo";
|
|
|
53435
53429
|
*/
|
|
53436
53430
|
class EtcdDataSource {
|
|
53437
53431
|
async getServiceList(dataSourceInfo) {
|
|
53432
|
+
const applicationServiceList = dataSourceInfo.instanceMode !== false ? await this.getApplicationServiceList(dataSourceInfo) : [];
|
|
53433
|
+
const interfaceServiceList = dataSourceInfo.interfaceMode !== false ? await this.getInterfaceServiceList(dataSourceInfo) : [];
|
|
53434
|
+
return {
|
|
53435
|
+
list: this.mergeServiceList(interfaceServiceList, applicationServiceList),
|
|
53436
|
+
separator: '.',
|
|
53437
|
+
packageSeparator: '.'
|
|
53438
|
+
};
|
|
53439
|
+
}
|
|
53440
|
+
async getInterfaceServiceList(dataSourceInfo) {
|
|
53441
|
+
const startTime = Date.now();
|
|
53438
53442
|
const children = await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getChildren(dataSourceInfo, PROVIDER_PREFIX);
|
|
53439
53443
|
const exculdeName = ["mapping", "config", "metadata"];
|
|
53440
53444
|
const serviceList = children.filter(e => !exculdeName.find(name => name == e)).map(e => {
|
|
@@ -53444,17 +53448,106 @@ class EtcdDataSource {
|
|
|
53444
53448
|
type: 'dubbo'
|
|
53445
53449
|
};
|
|
53446
53450
|
});
|
|
53447
|
-
|
|
53448
|
-
|
|
53449
|
-
|
|
53450
|
-
|
|
53451
|
-
|
|
53451
|
+
logger__WEBPACK_IMPORTED_MODULE_5___default().info(`【etcd接口模式】-查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
53452
|
+
return serviceList;
|
|
53453
|
+
}
|
|
53454
|
+
async getApplicationServiceList(dataSourceInfo) {
|
|
53455
|
+
const serviceList = [];
|
|
53456
|
+
let startTime = Date.now();
|
|
53457
|
+
try {
|
|
53458
|
+
serviceList.push(...(await this.getServiceListByApplicationMatedata(dataSourceInfo)));
|
|
53459
|
+
logger__WEBPACK_IMPORTED_MODULE_5___default().info(`【etcd应用模式】-查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
53460
|
+
} catch (e) {
|
|
53461
|
+
logger__WEBPACK_IMPORTED_MODULE_5___default().error(`【etcd应用模式】-查询服务列表 失败 耗时:${Date.now() - startTime}ms`, e);
|
|
53462
|
+
}
|
|
53463
|
+
if (dataSourceInfo.useApplicationMapping === true) {
|
|
53464
|
+
startTime = Date.now();
|
|
53465
|
+
try {
|
|
53466
|
+
serviceList.push(...(await this.getServiceListByMapping(dataSourceInfo, new Set(serviceList.map(item => item.serviceName)))));
|
|
53467
|
+
logger__WEBPACK_IMPORTED_MODULE_5___default().info(`【etcd应用模式-兜底反推】-查询服务列表 耗时:${Date.now() - startTime}ms`);
|
|
53468
|
+
} catch (e) {
|
|
53469
|
+
logger__WEBPACK_IMPORTED_MODULE_5___default().error(`【etcd应用模式-兜底反推】-查询服务列表 失败 耗时:${Date.now() - startTime}ms`, e);
|
|
53470
|
+
}
|
|
53471
|
+
}
|
|
53472
|
+
return serviceList;
|
|
53473
|
+
}
|
|
53474
|
+
async getServiceListByApplicationMatedata(dataSourceInfo) {
|
|
53475
|
+
const serviceList = [];
|
|
53476
|
+
for (const application of await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getChildren(dataSourceInfo, APPLICATION_PREFIX)) {
|
|
53477
|
+
const cache = new Set();
|
|
53478
|
+
for (const instance of await this.getAppInstanceList(dataSourceInfo, application)) {
|
|
53479
|
+
const revision = instance?.payload?.metadata?.["dubbo.metadata.revision"] || instance?.metadata?.["dubbo.metadata.revision"] || instance?.revision || instance?.metadata?.revision || instance?.metadata?.["metadata.revision"];
|
|
53480
|
+
if (!revision || cache.has(revision)) {
|
|
53481
|
+
continue;
|
|
53482
|
+
}
|
|
53483
|
+
cache.add(revision);
|
|
53484
|
+
const applicationMetadata = await this.getAppMetadata(dataSourceInfo, application, revision);
|
|
53485
|
+
if (!applicationMetadata?.services) {
|
|
53486
|
+
continue;
|
|
53487
|
+
}
|
|
53488
|
+
Object.values(applicationMetadata.services).forEach(service => {
|
|
53489
|
+
const serviceName = service.params?.interface || service.name || service.path;
|
|
53490
|
+
if (!serviceName) {
|
|
53491
|
+
return;
|
|
53492
|
+
}
|
|
53493
|
+
const primaryKey = `${application}:${serviceName}`;
|
|
53494
|
+
if (cache.has(primaryKey)) {
|
|
53495
|
+
return;
|
|
53496
|
+
}
|
|
53497
|
+
cache.add(primaryKey);
|
|
53498
|
+
serviceList.push({
|
|
53499
|
+
application,
|
|
53500
|
+
serviceName,
|
|
53501
|
+
uniqueServiceName: serviceName,
|
|
53502
|
+
type: 'dubbo'
|
|
53503
|
+
});
|
|
53504
|
+
});
|
|
53505
|
+
}
|
|
53506
|
+
}
|
|
53507
|
+
return serviceList;
|
|
53508
|
+
}
|
|
53509
|
+
async getServiceListByMapping(dataSourceInfo, excludeServiceNameSet) {
|
|
53510
|
+
const serviceList = [];
|
|
53511
|
+
const serviceNames = await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getChildren(dataSourceInfo, MAPPING_PREFIX);
|
|
53512
|
+
["configurators", "consumers", "providers", "routers"].forEach(name => excludeServiceNameSet.add(name));
|
|
53513
|
+
for (const serviceName of serviceNames) {
|
|
53514
|
+
if (excludeServiceNameSet.has(serviceName)) {
|
|
53515
|
+
continue;
|
|
53516
|
+
}
|
|
53517
|
+
const applications = ((await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getData(dataSourceInfo, `${MAPPING_PREFIX}/${serviceName}`)) || "").split(",").map(s => s.trim()).filter(Boolean);
|
|
53518
|
+
applications.forEach(application => {
|
|
53519
|
+
serviceList.push({
|
|
53520
|
+
application,
|
|
53521
|
+
serviceName,
|
|
53522
|
+
uniqueServiceName: serviceName,
|
|
53523
|
+
discoverMode: 'mapping'
|
|
53524
|
+
});
|
|
53525
|
+
});
|
|
53526
|
+
}
|
|
53527
|
+
return serviceList;
|
|
53528
|
+
}
|
|
53529
|
+
mergeServiceList(interfaceServiceList, applicationServiceList) {
|
|
53530
|
+
const applicationServiceNameSet = new Set(applicationServiceList.map(item => item.serviceName));
|
|
53531
|
+
const mergedList = [...applicationServiceList];
|
|
53532
|
+
interfaceServiceList.forEach(serviceInfo => {
|
|
53533
|
+
if (applicationServiceNameSet.has(serviceInfo.serviceName)) {
|
|
53534
|
+
return;
|
|
53535
|
+
}
|
|
53536
|
+
mergedList.push(serviceInfo);
|
|
53537
|
+
});
|
|
53538
|
+
return mergedList;
|
|
53452
53539
|
}
|
|
53453
53540
|
async getProviderList(dataSourceInfo, serviceInfo) {
|
|
53541
|
+
if (serviceInfo.application && serviceInfo.discoverMode !== 'mapping') {
|
|
53542
|
+
return await this.getApplicationProviderList(dataSourceInfo, serviceInfo);
|
|
53543
|
+
}
|
|
53454
53544
|
const serviceDisabledMap = new Map();
|
|
53455
53545
|
const serviceMetadataMap = new Map();
|
|
53456
53546
|
const array = [];
|
|
53457
53547
|
const entries = await this.getCategoryEntries(dataSourceInfo, serviceInfo, "providers");
|
|
53548
|
+
if (serviceInfo.discoverMode === 'mapping' && entries.length === 0) {
|
|
53549
|
+
throw new Error(`你当前接口是dubbo3应用模式,需要开启配置[dubbo.application.metadata-type=remote]才能获取到提供者列表`);
|
|
53550
|
+
}
|
|
53458
53551
|
for (let i = 0; i < entries.length; i++) {
|
|
53459
53552
|
let providerInfo = this.parseProviderInfo(entries[i]);
|
|
53460
53553
|
if (!providerInfo) {
|
|
@@ -53463,32 +53556,81 @@ class EtcdDataSource {
|
|
|
53463
53556
|
const disabledAddresses = await serviceDisabledMap.computeIfAbsent(this.buildConfigurationPath(providerInfo), async () => _main_common_DubboConfigurationUtils__WEBPACK_IMPORTED_MODULE_3__["default"].getDisableAddresses(await this.getJsonConfiguration(dataSourceInfo, serviceInfo, providerInfo)));
|
|
53464
53557
|
providerInfo.disabled = disabledAddresses.find(item => item === '0.0.0.0' || item === providerInfo.address) != null;
|
|
53465
53558
|
const metadata = await serviceMetadataMap.computeIfAbsent(this.buildMetaDataPath(providerInfo), async path => await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getJsonData(dataSourceInfo, path));
|
|
53466
|
-
|
|
53467
|
-
if (metadata) {
|
|
53468
|
-
metadata.methods.forEach(method => {
|
|
53469
|
-
methodList.push({
|
|
53470
|
-
...method,
|
|
53471
|
-
name: `${method.name}(${method.parameterTypes.map(pp => pp.substring(pp.lastIndexOf(".") + 1))})`,
|
|
53472
|
-
methodName: method.name,
|
|
53473
|
-
defaultParameter: JSON.stringify(_main_generator_ParamGeneratorAdapter__WEBPACK_IMPORTED_MODULE_4__["default"].generateParam(metadata, method.name), null, 2) || "[]"
|
|
53474
|
-
});
|
|
53475
|
-
});
|
|
53476
|
-
} else {
|
|
53477
|
-
providerInfo.methods.forEach(method => {
|
|
53478
|
-
methodList.push({
|
|
53479
|
-
name: method,
|
|
53480
|
-
methodName: method,
|
|
53481
|
-
parameterTypes: [],
|
|
53482
|
-
defaultParameter: "[]",
|
|
53483
|
-
returnType: null
|
|
53484
|
-
});
|
|
53485
|
-
});
|
|
53486
|
-
}
|
|
53487
|
-
providerInfo.methods = methodList;
|
|
53559
|
+
providerInfo.methods = this.resolveMethodList(providerInfo.methods, metadata);
|
|
53488
53560
|
array.push(providerInfo);
|
|
53489
53561
|
}
|
|
53490
53562
|
return array;
|
|
53491
53563
|
}
|
|
53564
|
+
async getApplicationProviderList(dataSourceInfo, serviceInfo) {
|
|
53565
|
+
const {
|
|
53566
|
+
application,
|
|
53567
|
+
serviceName
|
|
53568
|
+
} = serviceInfo;
|
|
53569
|
+
const providerList = [];
|
|
53570
|
+
const cache = new Map();
|
|
53571
|
+
const instanceList = await this.getAppInstanceList(dataSourceInfo, application);
|
|
53572
|
+
for (const instance of instanceList) {
|
|
53573
|
+
const revision = instance?.payload?.metadata?.["dubbo.metadata.revision"] || instance?.metadata?.["dubbo.metadata.revision"] || instance?.revision || instance?.metadata?.revision || instance?.metadata?.["metadata.revision"];
|
|
53574
|
+
if (!revision) {
|
|
53575
|
+
continue;
|
|
53576
|
+
}
|
|
53577
|
+
const appMetadata = await cache.computeIfAbsent(`a-${revision}`, () => this.getAppMetadata(dataSourceInfo, application, revision));
|
|
53578
|
+
if (!appMetadata || !appMetadata.services) {
|
|
53579
|
+
continue;
|
|
53580
|
+
}
|
|
53581
|
+
const appServiceMetadatas = Object.values(appMetadata.services).filter(service => {
|
|
53582
|
+
return (service.params?.interface || service.name || service.path) === serviceName;
|
|
53583
|
+
});
|
|
53584
|
+
for (const appServiceMetadata of appServiceMetadatas) {
|
|
53585
|
+
const providerInfo = this.parseApplicationProviderInfo(instance, serviceInfo, appServiceMetadata);
|
|
53586
|
+
const metadata = await cache.computeIfAbsent(`s-${providerInfo.version}-${providerInfo.group}`, () => {
|
|
53587
|
+
return this.getServiceMetadata(dataSourceInfo, application, serviceName, providerInfo.version, providerInfo.group);
|
|
53588
|
+
});
|
|
53589
|
+
providerInfo.methods = this.resolveMethodList(providerInfo.methods, metadata);
|
|
53590
|
+
providerList.push(providerInfo);
|
|
53591
|
+
}
|
|
53592
|
+
}
|
|
53593
|
+
return providerList;
|
|
53594
|
+
}
|
|
53595
|
+
resolveMethodList(methods, metadata) {
|
|
53596
|
+
if (metadata && metadata.methods?.length > 0) {
|
|
53597
|
+
return metadata.methods.map(method => ({
|
|
53598
|
+
...method,
|
|
53599
|
+
name: `${method.name}(${(method.parameterTypes || []).map(pp => pp.substring(pp.lastIndexOf(".") + 1))})`,
|
|
53600
|
+
methodName: method.name,
|
|
53601
|
+
defaultParameter: JSON.stringify(_main_generator_ParamGeneratorAdapter__WEBPACK_IMPORTED_MODULE_4__["default"].generateParam(metadata, method.name), null, 2) || "[]"
|
|
53602
|
+
}));
|
|
53603
|
+
}
|
|
53604
|
+
return (methods || []).map(method => ({
|
|
53605
|
+
name: method,
|
|
53606
|
+
methodName: method,
|
|
53607
|
+
parameterTypes: [],
|
|
53608
|
+
defaultParameter: "[]",
|
|
53609
|
+
returnType: null
|
|
53610
|
+
}));
|
|
53611
|
+
}
|
|
53612
|
+
parseApplicationProviderInfo(instanceData, serviceInfo, applicationMetadata) {
|
|
53613
|
+
const metadataParams = {
|
|
53614
|
+
...applicationMetadata.allParams,
|
|
53615
|
+
...applicationMetadata.params
|
|
53616
|
+
};
|
|
53617
|
+
const ip = instanceData.address || instanceData.ip || instanceData.host;
|
|
53618
|
+
const port = applicationMetadata.port || instanceData.port;
|
|
53619
|
+
return {
|
|
53620
|
+
ip,
|
|
53621
|
+
port,
|
|
53622
|
+
address: `${ip}:${port}`,
|
|
53623
|
+
protocol: applicationMetadata.protocol,
|
|
53624
|
+
application: serviceInfo.application,
|
|
53625
|
+
serviceName: serviceInfo.serviceName,
|
|
53626
|
+
uniqueServiceName: serviceInfo.uniqueServiceName || serviceInfo.serviceName,
|
|
53627
|
+
version: applicationMetadata.version || metadataParams?.version || '',
|
|
53628
|
+
group: applicationMetadata.group || metadataParams?.group || '',
|
|
53629
|
+
methods: Array.from(new Set((metadataParams.methods || "").split(",").filter(Boolean))),
|
|
53630
|
+
revision: metadataParams.revision,
|
|
53631
|
+
dubboVersion: metadataParams.release
|
|
53632
|
+
};
|
|
53633
|
+
}
|
|
53492
53634
|
async getConsumerList(dataSourceInfo, serviceInfo) {
|
|
53493
53635
|
const entries = await this.getCategoryEntries(dataSourceInfo, serviceInfo, "consumers");
|
|
53494
53636
|
return entries.map(data => this.parseConsumerInfo(data)).filter(Boolean);
|
|
@@ -53514,7 +53656,7 @@ class EtcdDataSource {
|
|
|
53514
53656
|
await this.doSaveConfiguration(dataSourceInfo, providerInfo, _main_common_YamlUtils__WEBPACK_IMPORTED_MODULE_1__["default"].yamlToJSON(ymal));
|
|
53515
53657
|
}
|
|
53516
53658
|
async invokeMethod(dataSourceInfo, serviceInfo, provder, methodInfo, code, invokerType) {
|
|
53517
|
-
return await
|
|
53659
|
+
return await _main_invoker___WEBPACK_IMPORTED_MODULE_6__["default"].invokeMethod(provder, methodInfo, code, invokerType);
|
|
53518
53660
|
}
|
|
53519
53661
|
async doSaveConfiguration(dataSourceInfo, providerInfo, doc) {
|
|
53520
53662
|
if (!doc || !doc.configs || doc.configs.length == 0) {
|
|
@@ -53541,16 +53683,18 @@ class EtcdDataSource {
|
|
|
53541
53683
|
const {
|
|
53542
53684
|
application,
|
|
53543
53685
|
serviceName,
|
|
53544
|
-
version
|
|
53686
|
+
version,
|
|
53687
|
+
group
|
|
53545
53688
|
} = providerInfo;
|
|
53546
|
-
return
|
|
53689
|
+
return this.buildServiceMetadataPath(application, serviceName, version, group);
|
|
53547
53690
|
}
|
|
53548
53691
|
buildConfigurationPath(providerInfo) {
|
|
53549
53692
|
let {
|
|
53550
53693
|
serviceName,
|
|
53551
|
-
version
|
|
53694
|
+
version,
|
|
53695
|
+
group
|
|
53552
53696
|
} = providerInfo;
|
|
53553
|
-
return `/dubbo/config/dubbo/${serviceName}:${version ? version : ""}
|
|
53697
|
+
return `/dubbo/config/dubbo/${serviceName}:${version ? version : ""}:${group || ""}.configurators`;
|
|
53554
53698
|
}
|
|
53555
53699
|
parseProviderInfo(data) {
|
|
53556
53700
|
if (!this.isDubboUrl(data)) {
|
|
@@ -53565,6 +53709,7 @@ class EtcdDataSource {
|
|
|
53565
53709
|
serviceName: urlData.params.interface,
|
|
53566
53710
|
uniqueServiceName: urlData.params.interface,
|
|
53567
53711
|
version: urlData.params.version,
|
|
53712
|
+
group: urlData.params.group,
|
|
53568
53713
|
weight: urlData.params.weight,
|
|
53569
53714
|
deprecated: urlData.params.deprecated,
|
|
53570
53715
|
protocol: urlData.protocol,
|
|
@@ -53588,6 +53733,7 @@ class EtcdDataSource {
|
|
|
53588
53733
|
disabled: false,
|
|
53589
53734
|
timeout: urlData.params.timeout,
|
|
53590
53735
|
version: urlData.params.version,
|
|
53736
|
+
group: urlData.params.group,
|
|
53591
53737
|
retries: urlData.params.retries || 2,
|
|
53592
53738
|
providerVersion: urlData.params.revision,
|
|
53593
53739
|
dubboVersion: urlData.params.release,
|
|
@@ -53602,6 +53748,54 @@ class EtcdDataSource {
|
|
|
53602
53748
|
timestamp: urlData.params.timestamp
|
|
53603
53749
|
};
|
|
53604
53750
|
}
|
|
53751
|
+
async getAppInstanceList(dataSourceInfo, application) {
|
|
53752
|
+
const prefix = `${APPLICATION_PREFIX}/${application}/`;
|
|
53753
|
+
const kvs = await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getPrefix(dataSourceInfo, prefix);
|
|
53754
|
+
return kvs.map(({
|
|
53755
|
+
key,
|
|
53756
|
+
value
|
|
53757
|
+
}) => {
|
|
53758
|
+
const data = value || decodeURIComponent(key.substring(prefix.length).split("/").filter(Boolean)[0] || "");
|
|
53759
|
+
return this.parseAppInstanceData(data, application);
|
|
53760
|
+
}).filter(instance => instance && (instance.address || instance.ip || instance.host || instance.revision || instance.metadata || instance.payload));
|
|
53761
|
+
}
|
|
53762
|
+
async getAppMetadata(dataSourceInfo, application, revision) {
|
|
53763
|
+
return (await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getJsonData(dataSourceInfo, `${METADATA_PREFIX}/${application}/${revision}`)) || {};
|
|
53764
|
+
}
|
|
53765
|
+
async getServiceMetadata(dataSourceInfo, application, serviceName, version, group) {
|
|
53766
|
+
return (await _EtcdClientUtils__WEBPACK_IMPORTED_MODULE_2__["default"].getJsonData(dataSourceInfo, this.buildServiceMetadataPath(application, serviceName, version, group))) || {};
|
|
53767
|
+
}
|
|
53768
|
+
buildServiceMetadataPath(application, serviceName, version) {
|
|
53769
|
+
return `/dubbo/metadata/${serviceName}/${version || ""}/provider/${application}`;
|
|
53770
|
+
}
|
|
53771
|
+
parseAppInstanceData(data, application) {
|
|
53772
|
+
if (!data) {
|
|
53773
|
+
return {};
|
|
53774
|
+
}
|
|
53775
|
+
if (typeof data !== 'string') {
|
|
53776
|
+
return data;
|
|
53777
|
+
}
|
|
53778
|
+
try {
|
|
53779
|
+
return JSON.parse(data);
|
|
53780
|
+
} catch (error) {
|
|
53781
|
+
const content = decodeURIComponent(data);
|
|
53782
|
+
if (!this.isDubboUrl(content)) {
|
|
53783
|
+
return {};
|
|
53784
|
+
}
|
|
53785
|
+
const urlData = _common_UrlUtils__WEBPACK_IMPORTED_MODULE_0__["default"].parseURL(content);
|
|
53786
|
+
return {
|
|
53787
|
+
name: application,
|
|
53788
|
+
address: urlData.host,
|
|
53789
|
+
ip: urlData.host,
|
|
53790
|
+
port: urlData.port,
|
|
53791
|
+
metadata: urlData.params,
|
|
53792
|
+
payload: {
|
|
53793
|
+
metadata: urlData.params
|
|
53794
|
+
},
|
|
53795
|
+
revision: urlData.params.revision || urlData.params["metadata.revision"] || urlData.params["dubbo.metadata.revision"]
|
|
53796
|
+
};
|
|
53797
|
+
}
|
|
53798
|
+
}
|
|
53605
53799
|
}
|
|
53606
53800
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EtcdDataSource);
|
|
53607
53801
|
|
package/package.json
CHANGED
package/docs/.DS_Store
DELETED
|
Binary file
|
package/public/.DS_Store
DELETED
|
Binary file
|
package/public/jar/.DS_Store
DELETED
|
Binary file
|