Skip to content

Commit 9fa9b6f

Browse files
YuZhangLarryrobocanicmarsevilspiritCopilotWyRainBow
authored
Merge upstream/develop into ai and add resolve MCP conflicts (#1470)
* feat: informer general framework and engine/discovery interface definition (#1314) * feat: informer general framework and engine/discovery interface definition * fix: ci problem; directory and dependency tidy (#1320) * fix: ci probelm; diretory and dependency tidy * fix: lack license header * rm: remove redundant file * ci(makefile): add makefile for ci (#1322) * ci(makefile): add makefile for ci * style(ci): rename dubbo-admin ci * delete unused ci (#1326) * fix: refractor web handler and service to fix compile error; (#1325) * fix: refractor web handler and service to fix compile error; * feat: support memory type of store (#1332) * feat: support memory type of store * fix: muilti indexes should use intersecection * simplify code Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refractor: GetByKeys return a list instead of map --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: support kubernetes as a backend engine (#1340) * feat: implement runtime engine using kubernetes * feat: Defined a unified error (#1353) * feat: unified error code; separate application handler and service into parts * fix: license header lack * fix: copilot review err fix * fix: simplify the if-else condition * chore: rename Error() to String() * chore: add extra String() in Error * feat: 新增listMeshes接口 * fix: copilot review * Implment Counter in local cache (#1345) * fix: update response interceptor to handle success and error messages more accurately (#1355) * feat(UI): Support multiple registries (#1356) * feat(#1352): Support multiple registries: add registry select box and refresh main area on change * doc(build): build ui * fix(#1352): Set first available mesh after login when no mesh is set * doc(build): build ui * fix(conflict) * doc(build): build ui * feat: implement mysql and postgresql store for resources (#1360) * feat: implement mysql and postgresql store for resources * fix some issues * ut: add some test cases * fix: dynamic table name * feat: implements discovery backend by nacos (#1367) * feat: support nacos2 to do discovery * refractor: abstract nacos and nacos service * fix: unit test and license header * fix: copilot review problem * chore: remove redundant code * fix counter bug (#1369) * fix: add indexer before init cause npe (#1372) * fix: add indexer before init cause npe * fix: unit test * Fix: Redirect to login page when receiving 401 unauthorized response from API (#1373) * feat: enhance error handling for unauthorized access and improve toast messages * feat: enhance error handling for unauthorized access and improve toast messages * fix: correct syntax error in response interceptor for redirect handling * Update ui-vue3/src/base/http/request.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: add YAML and XML editor components, update index references, and enhance error logging - Introduced new JavaScript files for YAML and XML syntax highlighting and editing capabilities. - Added a new component for updating YAML configurations with a structured editor interface. - Updated the index.html to reference the new JavaScript bundle for improved functionality. - Enhanced the HTTP request module to log errors during redirection on 401 responses for better debugging. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: implement discovery backend by zk (#1371) * feat: implements discovery backend by zk * feat: support components to start in dependency order (#1370) * feat: support components to start in dependency order * imporve * fix * fix error import * release changelog (#1376) * changelog * chore: rename refactor to enhancements * refactor: 🎨 Optimize UI styles and search functionality (#1379) * feat: enhance error handling for unauthorized access and improve toast messages * feat: enhance error handling for unauthorized access and improve toast messages * fix: correct syntax error in response interceptor for redirect handling * Update ui-vue3/src/base/http/request.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: add YAML and XML editor components, update index references, and enhance error logging - Introduced new JavaScript files for YAML and XML syntax highlighting and editing capabilities. - Added a new component for updating YAML configurations with a structured editor interface. - Updated the index.html to reference the new JavaScript bundle for improved functionality. - Enhanced the HTTP request module to log errors during redirection on 401 responses for better debugging. * docs: Only supports exact matching; remove the "prefix search" function from the placeholder (background word) * docs: All sorting indicators for lists are initially hidden, including but not limited to the list pages for applications, instances, services, and traffic management * refactor: 🎨 Optimize the styles of some tables and adapt to backend changes * docs: api baseurl --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(ui): Enhance service metrics display and optimize table UI styles (#1383) * build: Optimize the styles of some tables, adapt to backend changes, format the code, and package it * chore: remove PR_DESCRIPTION.md file as it is no longer needed * fix: update routing rule handling updated routing rule handling to use constants for HTTP status codes in various components. * build: build & format * feat: enhance error handling and data loading in various components (#1385) * build: Optimize the styles of some tables, adapt to backend changes, format the code, and package it * chore: remove PR_DESCRIPTION.md file as it is no longer needed * fix: update routing rule handling updated routing rule handling to use constants for HTTP status codes in various components. * build: build & format * feat: enhance error handling and data loading in various components - Added a silent error handling mechanism for specific URLs in the HTTP request module to suppress error messages. - Refactored data loading logic in sceneConfig.vue to load configuration data based on the selected tab, improving user experience. - Updated YAMLView.vue and other components to remove unused button code and optimize imports, enhancing code clarity and maintainability. - Improved error handling in routingRule and dynamicConfig components to ensure better user feedback and debugging. * feat: add new components and enhance YAML and XML editing capabilities - Introduced new JavaScript files for YAML and XML syntax highlighting and editing. - Added components for updating YAML configurations with structured editor interfaces. - Updated index.html to reference new JavaScript bundles for improved functionality. - Enhanced error handling and logging in various components for better debugging. - Removed unused code and optimized imports in YAMLView and related components. * feat: fix console bugs and makes console functions effective (#1378) * fix: console interfaces;feat: implements governor using zk and nacos * fix: instance subscriber * fix: unit-test * fix: rules search * resolve conflicts * fix: backend bugs * fix: rule handler and service refactor * fix: config error andd field mapping * fix: rename msg to message * fix: wrap prometheus error * fix ci * feat: add deploy manifests and fix metric and trace dashboard bugs (#1387) * feat: add monitoring/dubbo-samples-shop/dubbo-system resources * fix: metric, trace dashboard bug * Fix: Address the admin issues before the release (#1391) * build: Optimize the styles of some tables, adapt to backend changes, format the code, and package it * chore: remove PR_DESCRIPTION.md file as it is no longer needed * fix: update routing rule handling updated routing rule handling to use constants for HTTP status codes in various components. * build: build & format * feat: enhance error handling and data loading in various components - Added a silent error handling mechanism for specific URLs in the HTTP request module to suppress error messages. - Refactored data loading logic in sceneConfig.vue to load configuration data based on the selected tab, improving user experience. - Updated YAMLView.vue and other components to remove unused button code and optimize imports, enhancing code clarity and maintainability. - Improved error handling in routingRule and dynamicConfig components to ensure better user feedback and debugging. * feat: add new components and enhance YAML and XML editing capabilities - Introduced new JavaScript files for YAML and XML syntax highlighting and editing. - Added components for updating YAML configurations with structured editor interfaces. - Updated index.html to reference new JavaScript bundles for improved functionality. - Enhanced error handling and logging in various components for better debugging. - Removed unused code and optimized imports in YAMLView and related components. * feat: enhance UI components and improve error handling - Added global styles for clickable links in tables to improve user interaction. - Updated routing logic to utilize a dynamic header parameter key for better flexibility. - Enhanced error handling in HTTP requests to suppress messages for specific URLs. - Improved internationalization by adding new translation keys for 'Ready Time' in both English and Chinese. - Refactored various components to optimize code structure and maintainability, including updates to YAML and form views. - Adjusted table and form layouts for better responsiveness and user experience. * refactor: streamline component code and enhance condition handling - Simplified iframe rendering in GrafanaPage.vue for improved readability. - Added checks in ConfigModel.ts to skip undefined keys in matches and parameters. - Optimized YAMLView.vue by condensing MonacoEditor properties for better clarity. - Cleared default request and address matching arrays in formView.vue for cleaner initialization. - Enhanced condition parsing and merging logic in updateByFormView.vue to improve maintainability and readability. * build: build admin * fix: add Apache License headers to YAML files in release/kubernetes (#1393) * feat: enhance UI components, improve error handling, and add routing rule management (#1394) * build: Optimize the styles of some tables, adapt to backend changes, format the code, and package it * chore: remove PR_DESCRIPTION.md file as it is no longer needed * fix: update routing rule handling updated routing rule handling to use constants for HTTP status codes in various components. * build: build & format * feat: enhance error handling and data loading in various components - Added a silent error handling mechanism for specific URLs in the HTTP request module to suppress error messages. - Refactored data loading logic in sceneConfig.vue to load configuration data based on the selected tab, improving user experience. - Updated YAMLView.vue and other components to remove unused button code and optimize imports, enhancing code clarity and maintainability. - Improved error handling in routingRule and dynamicConfig components to ensure better user feedback and debugging. * feat: add new components and enhance YAML and XML editing capabilities - Introduced new JavaScript files for YAML and XML syntax highlighting and editing. - Added components for updating YAML configurations with structured editor interfaces. - Updated index.html to reference new JavaScript bundles for improved functionality. - Enhanced error handling and logging in various components for better debugging. - Removed unused code and optimized imports in YAMLView and related components. * feat: enhance UI components and improve error handling - Added global styles for clickable links in tables to improve user interaction. - Updated routing logic to utilize a dynamic header parameter key for better flexibility. - Enhanced error handling in HTTP requests to suppress messages for specific URLs. - Improved internationalization by adding new translation keys for 'Ready Time' in both English and Chinese. - Refactored various components to optimize code structure and maintainability, including updates to YAML and form views. - Adjusted table and form layouts for better responsiveness and user experience. * refactor: streamline component code and enhance condition handling - Simplified iframe rendering in GrafanaPage.vue for improved readability. - Added checks in ConfigModel.ts to skip undefined keys in matches and parameters. - Optimized YAMLView.vue by condensing MonacoEditor properties for better clarity. - Cleared default request and address matching arrays in formView.vue for cleaner initialization. - Enhanced condition parsing and merging logic in updateByFormView.vue to improve maintainability and readability. * build: build admin * fix: improve error handling and UI updates in GrafanaPage and sceneConfig components - Added conditional checks in GrafanaPage.vue to ensure valid baseURL before constructing the Grafana URL. - Enhanced iframe loading logic to prevent errors when accessing undefined elements. - Updated service.vue to handle potential undefined values in versionGroups, ensuring robust data handling. - Refactored sceneConfig.vue to improve the user experience by adding a conditional rendering for parameter routes, including a message for empty configurations and a button for adding new routes. * refactor: Request to update the Grafana URL * build: build * ♻️ refactor: update route parameters to include name and make pathId/appName optional Update routing structure across instance and traffic management views to: - Add :name parameter to routes for better identification - Make :pathId and :appName optional parameters (with ?) - Affects instance detail, monitor, link tracking, and configuration tabs - Updates dynamic config, routing rule, and tag rule views accordingly This change provides more flexible routing and better resource identification. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * ✨ feat(routing): add routing rule list component and composable Add new RoutingRuleList component and useRoutingRule composable to manage routing rule configurations. Updates addByFormView and updateByFormView to integrate with the new components. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * build: format & build * ✨ feat(routing): enhance routing rule form with comprehensive i18n support Enhance routing rule form functionality with improved internationalization, user interface refinements, and better form handling. - Add comprehensive i18n translations for routing rule fields - Improve form layout and field descriptions - Enhance routing rule list component with better UX - Refactor routing rule composable for better maintainability - Update tab header slots for improved navigation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * build: format & build --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> * Fix/console (#1397) * fix: create tag rule bug * refactor: config refactor; fix: fix console bugs * fix: instance disable traffic * fix: CI promblems * fix: typo * fix(ui): update footer copyright year to 2026 (#1396) * implement counter by key (#1390) * implement counter by key * chore: trigger CI * Fix counter initialization errors and mesh change detection logic --------- Co-authored-by: WyRainBow <your-email@example.com> * feat: kubernetes deployment manifests and docker file (#1410) * refactor: refactor dockerfile and implement dubbo-admin deployment * fix: deploy manifests * rm: remove useless files (#1416) * feat: implement distributed lock by gorm (#1432) * feat: add leader election for Discovery, Engine, Counter.(#1423) * feat: add leader election for Discovery and Engine components * fix: separate renew/acquire SQL and stop informers on demotion * feat: add leader election for Counter component * fix: resolve copilot review suggestion * fix: GormStore.Pool return value * Feat: Enhance service method retrieval and invocation features (#1429) * feat: add endpoint to retrieve service method names and corresponding request model * feat: add endpoint and logic to retrieve service method details * feat: trim whitespace from service name, mesh, group, version, and provider app name in ServiceMethodsReq * feat: enhance service method handling with overload support and signature retrieval * feat: add generic service invocation support * feat: refactor triple RPC instance selection to use a dedicated target struct * feat: remove obsolete service methods test file * feat: improve error handling in generic service invocation and add parameter count validation * feat: remove unnecessary variable and directly call service.InvokeServiceGeneric in ServiceGenericInvoke * feat: improve query validation by using strutil for blank checks and enhance service provider metadata indexing * feat: add endpoint to retrieve service provider instances and enhance request validation * feat: update service provider instance handling and improve request validation * feat: enhance generic service invocation with protocol and serialization support * feat: add normalization functions for JSON values in generic service invocation * feat: add normalization functions for JSON values in generic service invocation * feat: refine retry logic for service invocation failures * feat(ui-vue3): 添加 mock 数据支持,优化请求配置 - 添加环境变量 `VITE_MOCK_ENABLED` 用于启用 mock 数据模式 - 更新 `package.json` 脚本以添加 `dev:mock` 用于 mock 数据开发环境 - 新增 `mockLogin.ts` 文件,提供 mock 登录和登出接口 - 修改 `request.ts`,根据环境变量切换请求的 `baseURL` - 优化 `main.ts`,根据 mock 模式自动导入 mock API 并更新认证状态 * feat(ui-vue3): 新增 Axios 依赖和 mock 数据接口 - 新增 axios 作为 HTTP 客户端依赖 - 优化 mock 数据接口,包括应用指标、流量权重、灰度配置等 - 更新 package.json 文件以添加 axios 依赖 - 修改多个 mock 接口以适应新的架构和数据结构 * feat(api): 新增 mock 服务方法列表、详情及泛化调用接口 * feat(api): add front func * feat(ui-vue3): improve func empty description * feat(ui-vue3): code format * feat(api): update mock interface * feat(ui-vue3): add elapsed time display for service debug invoke * refactor: replace mockjs with MSW for API mocking Migrate from mockjs to Mock Service Worker (MSW) for a more realistic mock setup that intercepts at the network level. This eliminates the need for a separate mock baseURL and simplifies the mock architecture. - Remove mockjs dependency and all src/api/mock/* files - Add msw with browser worker and handler-based mock definitions - Move mock data to src/mocks/ with per-domain handler organization - Add shared API type definitions in src/types/api.ts - Simplify request.ts baseURL (always /api/v1, MSW handles interception) - Update main.ts mock initialization to use MSW worker * feat(api): refactor service request handling to use BaseServiceReq * feat(api): simplify service provider metadata lookup logic * feat(api): streamline service method resolution and metadata handling * feat(api): enhance ServiceGenericInvokeReq structure and streamline metadata handling * style(debug): format icon imports for improved readability * refactor(api): simplify splitGenericArrayType function by removing redundant checks * chore(deps): downgrade msw and related dependencies to version 2.11.6 * style(debug): improve debug tab UI with typography components and refined styles * style(debug): refine button and typography styles for improved consistency --------- Co-authored-by: 劳资蜀道山 <1493170339@qq.com> * feat: extend indexer with prefix matching and db persistence (#1422) * feat: extend indexer with prefix matching and db persistence * refactor: remove in-memory index from GormStore and add operator field * fix: copilot review suggestion and service panic * update * feat: unify and enhance the lifecycle of an instance (#1440) * feat: add lifecycle state management and color coding for instance statuses * feat: enhance instance lifecycle management with state derivation and UI updates * feat: improve resource handling in informer with enhanced error reporting * feat: enhance instance lifecycle logging with detailed merge and delete events * feat: implement ResourceKeyProvider interface for consistent key generation in informers * refactor: refactor instance resource handling and key function resolution in informers * refactor: remove unused deployState and registerState columns from instance table * feat: enhance runtime instance retrieval with improved matching logic and fallback handling * feat: improve runtime instance identification with enhanced error logging and filtering * feat: add pod watch selector and RPC port identifiers for improved service configuration * feat: add refresh button and localization support for improved user interaction * fix: fix lint * feat: enhance runtime instance retrieval with improved fallback handling and logging for ambiguous matches * fix: enhance instance lifecycle and deployment state management with new types and improved data handling * feat(eventbus): support per-subscriber async dispatch with graceful drain (#1455) * feat(eventbus): support per-subscriber async dispatch with graceful drain * refactor(config): unify AdminConfig method receivers as pointers * refactor(eventbus): move AsyncEnabled into Subscriber with docs * fix(config): keep read-only helpers on value receiver * refactor(config): unify AdminConfig receiver style * feat(mcp): add Model Context Protocol (MCP) server with HTTP transport and authentication ## Summary Implement Model Context Protocol (MCP) server for Dubbo Admin to enable AI integration through standardized tool interfaces. ## Key Features - **Modular Architecture**: Core components (server, registry, tools, transport, types) - **Comprehensive Tool Support**: 11 tools covering cluster info, service discovery, instance management, metrics, and application details - **Dual Transport Support**: - Stdio transport for local Claude Desktop integration - HTTP transport for remote connections with JSON-RPC 2.0 - **Security**: Optional Bearer Token authentication for HTTP endpoint ## Configuration ## Test plan - [x] Unit tests for core components - [x] Integration tests - [x] Manual testing with Claude Desktop Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Service/Application Dependency Graph Implement (#1460) * feat(ui): Added application and service topology mapping feature * style(ui-vue3): Add a minimum width to the login form and remove unnecessary blank lines * Feat: Add service and application topology graph APIs based on discussion #1398 * feat(api): add GraphServices endpoint for service-level topology Based on discussion #1398, use ServiceProviderMetadata and ServiceConsumerMetadata to return provider/consumer application relations as graph nodes and edges for AntV G6. * feat(api): add GraphApplications endpoint for application-level topology Traverse provider/consumer service relations to build application-level graph. Also add idx_service_consumer_service_key index to support efficient serviceKey queries. * feat(api): add graph models (GraphNode, GraphEdge, GraphData) in pkg/console/model/graph.go * feat(api): add ApplicationGraphReq, ServiceGraphReq and GetApplicationGraph, GetServiceGraph handlers * feat(router): register /application/graph and /service/graph routes * feat(api): fix error handling to use direct err pass-through instead of MeshNotFoundError * Feat: Enhance service metadata derivation and detail retrieval ([#1430](#1430)) * feat(api): replace Service.{providers,consumers,features} with {methods} field Simplify Service proto by removing providers, consumers, and features map, keeping only the aggregated methods list derived from provider metadata. * feat(api): derive Service resource from ServiceProviderMetadata on add/update/delete ServiceProviderMetadataEventSubscriber now maintains Service resources by aggregating methods from all provider instances sharing the same serviceKey. Handles add, update, and delete events to keep Service spec in sync. * feat(api): add language detection from provider metadata parameters Detect provider language (golang/java) from metadata parameters and method type signatures when explicit language field is absent. * feat(api): add GetServiceDetail endpoint returning language and methods Add GET /service/detail returning ServiceDetailResp with language and aggregated method names from the derived Service resource. * feat(api): add BuildServiceIdentityKey helper for {service}:{version}:{group} * feat(api): add ByServiceName index for ServiceKind * feat(api): refactor SearchServices to query ServiceResource directly SearchServices and SearchServicesByKeywords now use ServiceResource instead of ServiceProviderMetadataResource for service listing. * feat(api): remove providerAppName from ServiceSearchResp and ServiceTabDistributionReq * feat(api): add ServiceDetailReq and ServiceDetailResp models * feat(router): register /service/detail and /service/interfaces routes * feat(ui-vue3): remove providerAppName from grafana types and tab components * chore: Add G6 chart library and its dependencies to the project * chore(assets): Add Apache license and format code for iconfont file * fix: Correct the naming errors in the application topology graph API parameters and improve the code comments * chore: minor cleanup - fix comment language and import order * chore: translate Chinese comment to English in GraphApplications error handling * chore: reorder imports in service_provider_metadata.go * fix:Fix parameter passing error when obtaining application details * fix: fix type mismatch and index issues in service search and metadata sync 1. pkg/console/service/service.go:132 - fix generic type mismatch with resourceKind - generic ServiceResource should use ServiceKind, was incorrectly passing ServiceProviderMetadataKind - index changed from ByServiceProviderServiceName to ByServiceName (aligned with ServiceKind) 2. pkg/core/discovery/subscriber/service_provider_metadata.go - processUpdate: remove redundant oldRes key check (oldKey always equals newKey in same resource update, else branch is unreachable dead code) - syncService: use ByServiceProviderServiceKey index instead of ByServiceProviderServiceName + manual version/group filtering, reduces data returned from DB and improves performance Ref: [1460](#1460 (comment)) * Feat: Add coding agent domain skills ([#1457](#1457)) * feat(skills): add backend domain skills for runtime, discovery, engine, events, store, and Console API Document component lifecycle, ListAndWatch discovery, resource engine behavior, EventBus dispatching, storage indexes, and Web MVC flow for coding agents. * feat(skills): add frontend domain skill for routing, components, and traffic rule forms Document Vue frontend structure, API clients, Pinia state, route metadata, layout tabs, and traffic rule form design. * feat(skills): add OpenAI skill metadata Add agents/openai.yaml metadata for each dubbo-admin domain skill. * fix(console): use ServiceKind for service list search Query ServiceResource from ServiceKind instead of ServiceProviderMetadataKind so the non-keyword service list path uses the matching resource store and index set. --------- Co-authored-by: sohandsomejie <3080955413@qq.com> Co-authored-by: MoChengqian <2972013548@qq.com> --------- Co-authored-by: robb <robocanic@gmail.com> Co-authored-by: marsevilspirit <marsevilspirit@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: WyRainBow <weiyu9484@gmail.com> Co-authored-by: LGgbond <1493170339@qq.com> Co-authored-by: Helltab <939255879@qq.com> Co-authored-by: Tew <finntew@outlook.com> Co-authored-by: EVERFID <166227111+everfid-ever@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Akshit Vig <akshitvig48@gmail.com> Co-authored-by: WyRainBow <your-email@example.com> Co-authored-by: EVERFID <3085640487@qq.com> Co-authored-by: ThunGuo <tew@apache.org> Co-authored-by: Zerui Yang <zeruiyoung@gmail.com> Co-authored-by: LunaRain_079 <2074730050@qq.com> Co-authored-by: Comrade Yi <119987662+ambiguous-pointer@users.noreply.github.com> Co-authored-by: sohandsomejie <3080955413@qq.com> Co-authored-by: MoChengqian <2972013548@qq.com>
1 parent 1df75cd commit 9fa9b6f

782 files changed

Lines changed: 159482 additions & 23697 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: dubbo-admin-console-api
3+
description: Implements and reviews dubbo-admin Console API changes. Use when the user asks about HTTP endpoints, Gin routes, handlers, request or response models, console services, error handling, API pagination, or the handler to service to manager to store flow under pkg/console/. Do not use for frontend-only, discovery-only, or store-internals tasks unless they affect Console API behavior.
4+
---
5+
6+
# dubbo-admin Console API
7+
8+
## Purpose
9+
10+
Use this skill to change or explain dubbo-admin Web MVC behavior consistently across router, handler, model, service, manager, and store layers.
11+
12+
## When to use
13+
14+
Use for Console API endpoint additions, request binding, response models, service logic, route registration, API error handling, and backend API review.
15+
16+
Do not use for Vue-only changes, registry discovery internals, or memory store implementation details unless an API contract depends on them.
17+
18+
## Inputs
19+
20+
Required:
21+
- Target endpoint, handler, model, or package path.
22+
- Intended API behavior or observed bug.
23+
24+
Optional:
25+
- Example request or response payload.
26+
- Related frontend API caller.
27+
- Existing route or service function to mirror.
28+
29+
If missing, inspect `pkg/console/router/router.go` first and ask only for behavior that cannot be inferred from code.
30+
31+
## Workflow
32+
33+
1. Locate the route in `pkg/console/router/router.go`.
34+
2. Read the matching handler in `pkg/console/handler/` for binding and response style.
35+
3. Read or update request and response types in `pkg/console/model/`.
36+
4. Put business logic in `pkg/console/service/`; keep handlers focused on HTTP concerns.
37+
5. Use `ctx.ResourceManager()` and helpers in `pkg/core/manager/` for resource access.
38+
6. Return responses with `model.NewSuccessResp`, `util.HandleArgumentError`, or `util.HandleServiceError`.
39+
7. If endpoint behavior is unclear, read `references/web-mvc-flow.md`.
40+
41+
## Output format
42+
43+
Return changed files, endpoint behavior, request and response contract, validation performed, and any frontend impact.
44+
45+
## Validation
46+
47+
- Confirm the route is registered under `/api/v1`.
48+
- Confirm handler binding matches method semantics: query for reads, JSON body for mutations.
49+
- Confirm service code returns typed models and propagates business errors.
50+
- Run focused Go tests for changed packages; use `make test` for shared API behavior.
51+
52+
## Edge cases
53+
54+
- Some handlers include lightweight auth, cookie, or parameter logic; do not force all logic into services.
55+
- If changing response fields, check frontend callers under `ui-vue3/src/api/`.
56+
- If a resource query becomes slow, switch to `dubbo-admin-store`.
57+
58+
## References
59+
60+
- Read `references/web-mvc-flow.md` for the current route, handler, service, and response pattern.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"skill_name": "dubbo-admin-console-api",
3+
"evals": [
4+
{
5+
"id": "obvious-trigger",
6+
"prompt": "Add a new GET endpoint under /api/v1/service that returns a typed response from pkg/console/service.",
7+
"expected_behavior": "Use the Console API router, handler, model, service, and manager workflow."
8+
},
9+
{
10+
"id": "paraphrased-trigger",
11+
"prompt": "The admin backend route binds query parameters incorrectly and returns the wrong CommonResp data.",
12+
"expected_behavior": "Inspect pkg/console handlers, models, services, and response helpers."
13+
},
14+
{
15+
"id": "file-based-trigger",
16+
"prompt": "Review changes in pkg/console/router/router.go and pkg/console/handler/application.go.",
17+
"expected_behavior": "Use this skill because Console API files are touched."
18+
},
19+
{
20+
"id": "no-trigger",
21+
"prompt": "Change the Vue sidebar icon for the service page.",
22+
"expected_behavior": "Do not use this skill; use the frontend skill."
23+
},
24+
{
25+
"id": "conflict-trigger",
26+
"prompt": "A frontend API call fails because the backend response field changed.",
27+
"expected_behavior": "Use this skill for backend contract review and coordinate with frontend skill for caller updates."
28+
}
29+
]
30+
}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Console API Web MVC Implementation
2+
3+
This reference explains how dubbo-admin exposes backend HTTP APIs through Gin handlers, typed models, console services, resource managers, and stores.
4+
5+
## End-to-end call chain
6+
7+
```text
8+
runtime.RegisterComponent(&consoleWebServer{})
9+
-> Bootstrap initializes consoleWebServer.Init
10+
-> Init creates gin.Engine, middleware, static UI, health route
11+
-> Runtime starts consoleWebServer.Start
12+
-> Start creates consolectx.NewConsoleContext(coreRt)
13+
-> router.InitRouter(c.Engine, c.cs)
14+
-> HTTP request under /api/v1
15+
-> handler binds query/path/body
16+
-> handler calls service function
17+
-> service uses consolectx.Context and ctx.ResourceManager()
18+
-> manager/store reads or writes resources
19+
-> service returns typed model response
20+
-> handler wraps with model.NewSuccessResp or util.Handle*Error
21+
```
22+
23+
## Console component
24+
25+
Key file: `pkg/console/component.go`
26+
27+
Console is registered as a runtime component and depends on `runtime.ResourceManager`:
28+
29+
```go
30+
func init() {
31+
runtime.RegisterComponent(&consoleWebServer{})
32+
}
33+
34+
func (c *consoleWebServer) RequiredDependencies() []runtime.ComponentType {
35+
return []runtime.ComponentType{runtime.ResourceManager}
36+
}
37+
```
38+
39+
`Init` sets up Gin:
40+
41+
- embedded admin UI mounted at `/admin`
42+
- SPA fallback for `/admin/**`
43+
- `/health` endpoint
44+
- cookie session store
45+
- auth middleware
46+
- zap logging and recovery middleware
47+
- Gin mode from config
48+
49+
`Start` creates console context and registers `/api/v1` routes:
50+
51+
```go
52+
c.cs = consolectx.NewConsoleContext(coreRt)
53+
router.InitRouter(c.Engine, c.cs)
54+
httpServer := c.startHttpServer(errChan)
55+
```
56+
57+
On stop, the HTTP server shuts down with `Shutdown(context.Background())`.
58+
59+
## Auth behavior
60+
61+
`authMiddleware` skips paths ending in `/login`. Other requests require a session value named `user`. Missing user returns HTTP 401 with `model.NewBizErrorResp`.
62+
63+
This means many API handlers assume authentication already passed.
64+
65+
## Console context
66+
67+
Key file: `pkg/console/context/context.go`
68+
69+
`consolectx.Context` wraps runtime access:
70+
71+
```go
72+
type Context interface {
73+
ResourceManager() manager.ResourceManager
74+
CounterManager() counter.CounterManager
75+
Config() app.AdminConfig
76+
AppContext() context.Context
77+
LockManager() lock.Lock
78+
}
79+
```
80+
81+
`ResourceManager()` retrieves the runtime ResourceManager component and returns its manager:
82+
83+
```go
84+
rmc, _ := c.coreRt.GetComponent(runtime.ResourceManager)
85+
return rmc.(manager.ResourceManagerComponent).ResourceManager()
86+
```
87+
88+
CounterManager and LockManager are optional and may return nil.
89+
90+
## Route registration
91+
92+
Key file: `pkg/console/router/router.go`
93+
94+
All Console API routes are grouped under `/api/v1`:
95+
96+
```go
97+
router := r.Group("/api/v1")
98+
```
99+
100+
Common groups include:
101+
102+
- `/auth`
103+
- `/instance`
104+
- `/application`
105+
- `/service`
106+
- `/configurator`
107+
- `/condition-rule`
108+
- `/tag-rule`
109+
- global `/search`, `/overview`, `/metadata`, `/meshes`
110+
111+
When adding an endpoint, register the route in the existing group that matches frontend URL structure.
112+
113+
## Handler pattern
114+
115+
Handlers usually close over `consolectx.Context` and return `gin.HandlerFunc`:
116+
117+
```go
118+
func GetApplicationDetail(ctx consolectx.Context) gin.HandlerFunc {
119+
return func(c *gin.Context) {
120+
req := &model.ApplicationDetailReq{}
121+
if err := c.ShouldBindQuery(req); err != nil {
122+
util.HandleArgumentError(c, err)
123+
return
124+
}
125+
resp, err := service.GetApplicationDetail(ctx, req)
126+
if err != nil {
127+
util.HandleServiceError(c, err)
128+
return
129+
}
130+
c.JSON(http.StatusOK, model.NewSuccessResp(resp))
131+
}
132+
}
133+
```
134+
135+
Read endpoints commonly use `ShouldBindQuery`. Mutation endpoints commonly use `ShouldBindJSON` or path parameters depending on existing handler style.
136+
137+
## Error and response model
138+
139+
Key files:
140+
141+
- `pkg/console/model/common.go`
142+
- `pkg/console/util/error.go`
143+
144+
Success response:
145+
146+
```go
147+
model.NewSuccessResp(data)
148+
```
149+
150+
Service errors are normalized to `bizerror.Error` and returned with HTTP 200:
151+
152+
```go
153+
func HandleServiceError(ctx *gin.Context, err error) {
154+
var e bizerror.Error
155+
if !errors.As(err, &e) {
156+
e = bizerror.New(bizerror.UnknownError, err.Error())
157+
}
158+
ctx.JSON(http.StatusOK, model.NewBizErrorResp(e))
159+
}
160+
```
161+
162+
Argument errors use `bizerror.InvalidArgument`. Auth middleware is an exception and returns HTTP 401.
163+
164+
## Service layer
165+
166+
Key directory: `pkg/console/service/`
167+
168+
Services receive `consolectx.Context` and typed request models. They usually access resources through generic manager helpers or `ctx.ResourceManager()` directly.
169+
170+
Typical resource query:
171+
172+
```go
173+
resources, err := manager.ListByIndexes[*meshresource.ServiceProviderMetadataResource](
174+
ctx.ResourceManager(),
175+
meshresource.ServiceProviderMetadataKind,
176+
[]index.IndexCondition{...},
177+
)
178+
```
179+
180+
Do not put store/index details into handlers. Keep HTTP binding in handlers and resource logic in services.
181+
182+
## Frontend contract
183+
184+
Frontend API callers live under `ui-vue3/src/api/`. If a response field, request parameter, or endpoint path changes, check both Console model structs and frontend caller usage.
185+
186+
## Common failure modes
187+
188+
- Route registered under wrong group or duplicate service group block.
189+
- Handler binds query when frontend sends JSON, or vice versa.
190+
- Model tags do not match frontend parameter names.
191+
- Service returns raw resource shape not expected by frontend view.
192+
- Error returned directly instead of through `util.HandleServiceError`.
193+
- Optional managers such as CounterManager or LockManager are nil.
194+
195+
## Review checklist
196+
197+
- Route path and HTTP method match frontend usage.
198+
- Handler binding matches request source.
199+
- Request/response models have correct tags and JSON field names.
200+
- Service owns business logic and uses ResourceManager/store helpers.
201+
- Response uses `CommonResp` consistently.
202+
- Frontend API client is updated when contract changes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: dubbo-admin-discovery
3+
description: Implements and reviews dubbo-admin registry discovery changes. Use when the user asks about Zookeeper or Nacos discovery, ListAndWatch, informers, discovery factories, discovery subscribers, ServiceProviderMetadata or ServiceConsumerMetadata processing, or Application, Service, RPCInstance, and Instance derivation under pkg/core/discovery/ and pkg/core/controller/. Do not use for engine-sourced RuntimeInstance behavior.
4+
---
5+
6+
# dubbo-admin Discovery
7+
8+
## Purpose
9+
10+
Use this skill to trace registry-sourced resources from ListWatcher input through informer events, EventBus dispatch, subscribers, store writes, and derived mesh resources.
11+
12+
## When to use
13+
14+
Use for Zookeeper or Nacos registry flow, discovery ListWatchers, discovery subscribers, metadata-derived services, application instance counts, and registry event bugs.
15+
16+
Do not use for Kubernetes runtime infrastructure engine flow; use `dubbo-admin-engine` for RuntimeInstance behavior.
17+
18+
## Inputs
19+
20+
Required:
21+
- Registry type, resource kind, subscriber, or discovery package path.
22+
- The event or resource transition being changed or debugged.
23+
24+
Optional:
25+
- Example registry metadata.
26+
- Store query or index involved.
27+
- Console API result affected by discovery data.
28+
29+
If missing, start at `pkg/core/discovery/component.go` and identify the subscriber for the resource kind.
30+
31+
## Workflow
32+
33+
1. Read `pkg/core/discovery/component.go` for dependencies, informer creation, subscriber registration, and start behavior.
34+
2. Inspect `pkg/core/controller/listwatcher.go` and `pkg/core/controller/informer.go`.
35+
3. Follow registry-specific ListWatcher creation through `pkg/core/discovery/factory.go`.
36+
4. Read the relevant subscriber under `pkg/core/discovery/subscriber/`.
37+
5. Verify resource writes against store and index behavior.
38+
6. Read `references/discovery-flow.md` for subscriber registration and event flow details.
39+
40+
## Output format
41+
42+
Return the resource flow, affected subscriber, store/index interactions, changed files, and validation commands or residual test gaps.
43+
44+
## Validation
45+
46+
- Confirm informer events emit the expected `cache.DeltaType`.
47+
- Confirm subscriber `ResourceKind()` matches the event resource kind.
48+
- Confirm derived resources use stable resource keys.
49+
- Run targeted subscriber or controller tests; use `make test` for broad discovery changes.
50+
51+
## Edge cases
52+
53+
- Nacos and Zookeeper register extra subscribers conditionally.
54+
- Delete events may need old objects and must not assume `NewObj()` exists.
55+
- If dispatch semantics are the problem, switch to `dubbo-admin-events`.
56+
57+
## References
58+
59+
- Read `references/discovery-flow.md` for ListWatcher, informer, and subscriber details.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"skill_name": "dubbo-admin-discovery",
3+
"evals": [
4+
{
5+
"id": "obvious-trigger",
6+
"prompt": "Fix ServiceProviderMetadataEventSubscriber so Service resources update after provider metadata deletion.",
7+
"expected_behavior": "Use discovery subscriber and informer event flow."
8+
},
9+
{
10+
"id": "paraphrased-trigger",
11+
"prompt": "Nacos registry changes are not reflected in applications shown by dubbo-admin.",
12+
"expected_behavior": "Trace registry ListWatcher, informer events, subscribers, and store writes."
13+
},
14+
{
15+
"id": "file-based-trigger",
16+
"prompt": "Review pkg/core/discovery/component.go and pkg/core/discovery/subscriber/service_consumer_metadata.go.",
17+
"expected_behavior": "Use this skill because discovery orchestration and subscribers are touched."
18+
},
19+
{
20+
"id": "no-trigger",
21+
"prompt": "Change how EventBus handles subscriber errors for all domains.",
22+
"expected_behavior": "Do not use this skill as primary; use dubbo-admin-events."
23+
},
24+
{
25+
"id": "conflict-trigger",
26+
"prompt": "A RuntimeInstance from Kubernetes is not merged into an Instance resource.",
27+
"expected_behavior": "Use dubbo-admin-engine, not discovery, because RuntimeInstance is engine-sourced."
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)