RockteMQ-AI commented on code in PR #3129:
URL: 
https://github.com/apache/rocketmq-dashboard/pull/3129#discussion_r3934018608


##########
web/src/utils/dataSourceCoverage.ts:
##########
@@ -0,0 +1,422 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://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.
+ */
+
+import type { Instance } from '../api/instance';
+import type { DataSource } from '../api/settings';
+
+export type DataSourceCoverageStatus = 'healthy' | 'warning' | 'critical' | 
'empty';
+export type DataSourceCoverageSeverity = 'critical' | 'warning' | 'info';
+export type DataSourceCoverageHealth = 'healthy' | 'warning' | 'unhealthy' | 
'untested';
+export type DataSourceScope = 'global' | 'scoped';
+
+export type DataSourceCoverageIssueCode =
+  | 'NO_INSTANCES'
+  | 'NO_DATA_SOURCES'
+  | 'INSTANCE_UNCOVERED'
+  | 'INSTANCE_NO_USABLE_SOURCE'
+  | 'INSTANCE_MULTIPLE_SAME_TYPE'
+  | 'INSTANCE_ONLY_UNTESTED'
+  | 'SOURCE_STALE_INSTANCE'
+  | 'SOURCE_UNHEALTHY'
+  | 'DUPLICATE_SOURCE_TARGET';
+
+export interface DataSourceCoverageIssue {
+  code: DataSourceCoverageIssueCode;
+  severity: DataSourceCoverageSeverity;
+  message: string;
+  instanceId?: string;
+  dataSourceKey?: string;
+  dataSourceKeys?: string[];
+  type?: string;
+}
+
+export interface DataSourceReference {
+  key: string;
+  name: string;
+  type: string;
+  url: string;
+  auth: string;

Review Comment:
   The `instanceAliases` function uses `instance.name`, `instance.id`, and 
`instance.endpoint` as matching keys. This covers the common cases well. One 
edge case to be aware of: if a data source references an endpoint with a port 
(e.g. `10.0.0.1:9090`) but the instance endpoint is stored without the port (or 
vice versa), the alias match would miss. The `normalizeUrl` function strips 
trailing slashes but preserves ports, so this should be consistent as long as 
both sides use the same format.



##########
web/src/utils/dataSourceCoverage.ts:
##########
@@ -0,0 +1,422 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://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.
+ */
+
+import type { Instance } from '../api/instance';
+import type { DataSource } from '../api/settings';
+
+export type DataSourceCoverageStatus = 'healthy' | 'warning' | 'critical' | 
'empty';
+export type DataSourceCoverageSeverity = 'critical' | 'warning' | 'info';
+export type DataSourceCoverageHealth = 'healthy' | 'warning' | 'unhealthy' | 
'untested';
+export type DataSourceScope = 'global' | 'scoped';
+
+export type DataSourceCoverageIssueCode =
+  | 'NO_INSTANCES'
+  | 'NO_DATA_SOURCES'
+  | 'INSTANCE_UNCOVERED'
+  | 'INSTANCE_NO_USABLE_SOURCE'
+  | 'INSTANCE_MULTIPLE_SAME_TYPE'
+  | 'INSTANCE_ONLY_UNTESTED'
+  | 'SOURCE_STALE_INSTANCE'
+  | 'SOURCE_UNHEALTHY'
+  | 'DUPLICATE_SOURCE_TARGET';
+
+export interface DataSourceCoverageIssue {

Review Comment:
   The `normalizeUrl` function silently returns the raw lowercased value when 
`new URL()` parsing fails. This is reasonable for resilience, but consider 
adding a `console.debug` or a warning log for unparseable URLs — it would help 
operators diagnose misconfigured data source endpoints.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to