feat(rocketmq): add agent and management console
This commit is contained in:
86 files changed
+12373
-505
No files matched your search
@@ -134,7 +134,50 @@ describe("connectionStore MQ sidebar tree", () => {
|
||||
|
||||
await store.refreshTreeNode(node);
|
||||
|
||||
expect(node.children?.map((child) => ({ label: child.label, tenant: child.mqTenant, initialTab: child.mqInitialTab }))).toEqual([{ label: "Topics", tenant: "_kafka", initialTab: "topics" }]);
|
||||
expect(node.children?.map((child) => ({ label: child.label, tenant: child.mqTenant, initialTab: child.mqInitialTab }))).toEqual([{ label: "Topics", tenant: "_flat_mq", initialTab: "topics" }]);
|
||||
});
|
||||
|
||||
it("adds a RocketMQ topics child with a topics initial tab", async () => {
|
||||
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));
|
||||
vi.doMock("@/lib/backend/api", () => ({
|
||||
checkConnectionHealth: vi.fn().mockResolvedValue(undefined),
|
||||
deleteSchemaCachePrefix: vi.fn().mockResolvedValue(undefined),
|
||||
listDatabases: vi.fn().mockResolvedValue([]),
|
||||
loadSchemaCache: vi.fn().mockResolvedValue(null),
|
||||
mqListTenants: vi.fn(),
|
||||
saveSchemaCache: vi.fn().mockResolvedValue(undefined),
|
||||
}));
|
||||
|
||||
const { useConnectionStore } = await import("@/stores/connectionStore");
|
||||
const store = useConnectionStore();
|
||||
const connection = {
|
||||
...kafkaConnection(),
|
||||
name: "Apache RocketMQ",
|
||||
driver_profile: "rocketmq",
|
||||
driver_label: "Apache RocketMQ",
|
||||
external_config: {
|
||||
systemKind: "rocketmq",
|
||||
adminUrl: "",
|
||||
auth: { kind: "none" },
|
||||
extra: { namesrvAddr: "127.0.0.1:9876" },
|
||||
},
|
||||
} as ConnectionConfig;
|
||||
const node: TreeNode = {
|
||||
id: connection.id,
|
||||
label: connection.name,
|
||||
type: "connection",
|
||||
connectionId: connection.id,
|
||||
isExpanded: false,
|
||||
children: [],
|
||||
};
|
||||
|
||||
store.connections = [connection];
|
||||
store.connectedIds.add(connection.id);
|
||||
store.treeNodes = [node];
|
||||
|
||||
await store.refreshTreeNode(node);
|
||||
|
||||
expect(node.children?.map((child) => ({ label: child.label, tenant: child.mqTenant, initialTab: child.mqInitialTab }))).toEqual([{ label: "Topics", tenant: "_flat_mq", initialTab: "topics" }]);
|
||||
});
|
||||
|
||||
it("detects Kafka from external config when driver profile is missing", async () => {
|
||||
@@ -168,7 +211,7 @@ describe("connectionStore MQ sidebar tree", () => {
|
||||
await store.refreshTreeNode(node);
|
||||
|
||||
expect(mqListTenants).not.toHaveBeenCalled();
|
||||
expect(node.children?.map((child) => ({ label: child.label, tenant: child.mqTenant, initialTab: child.mqInitialTab }))).toEqual([{ label: "Topics", tenant: "_kafka", initialTab: "topics" }]);
|
||||
expect(node.children?.map((child) => ({ label: child.label, tenant: child.mqTenant, initialTab: child.mqInitialTab }))).toEqual([{ label: "Topics", tenant: "_flat_mq", initialTab: "topics" }]);
|
||||
});
|
||||
|
||||
it("reuses an in-flight connection attempt instead of recording stale superseded errors", async () => {
|
||||
|
||||
@@ -116,10 +116,11 @@ function sidebarObjectGroupPageSize(): number {
|
||||
return typeof size === "number" && size > 0 ? size : 500;
|
||||
}
|
||||
|
||||
function isKafkaMqConnection(config: ConnectionConfig | undefined): boolean {
|
||||
function isFlatMqConnection(config: ConnectionConfig | undefined): boolean {
|
||||
if (!config || config.db_type !== "mq") return false;
|
||||
if (config.driver_profile === "kafka") return true;
|
||||
return (config.external_config as Partial<MqAdminConfig> | undefined)?.systemKind === "kafka";
|
||||
if (config.driver_profile === "kafka" || config.driver_profile === "rocketmq") return true;
|
||||
const kind = (config.external_config as Partial<MqAdminConfig> | undefined)?.systemKind;
|
||||
return kind === "kafka" || kind === "rocketmq";
|
||||
}
|
||||
|
||||
type ImportSource = "dbx" | "navicat" | "dbeaver" | "datagrip";
|
||||
@@ -2538,16 +2539,16 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
if (useCachedChildren(node, options)) return;
|
||||
|
||||
const config = getConfig(connectionId);
|
||||
if (isKafkaMqConnection(config)) {
|
||||
// Kafka has no tenant/namespace concept. Create a synthetic child
|
||||
if (isFlatMqConnection(config)) {
|
||||
// Kafka/RocketMQ have no tenant/namespace concept. Create a synthetic child
|
||||
// that opens the MQ admin console directly when clicked.
|
||||
setChildren(node, [
|
||||
{
|
||||
id: schemaCacheKey(connectionId, "mq-tenant", "_kafka"),
|
||||
id: schemaCacheKey(connectionId, "mq-tenant", "_flat_mq"),
|
||||
label: "Topics",
|
||||
type: "mq-tenant" as const,
|
||||
connectionId,
|
||||
mqTenant: "_kafka",
|
||||
mqTenant: "_flat_mq",
|
||||
mqInitialTab: "topics",
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user