|
| 1 | +--- |
| 2 | +name: dubbo-go-domain |
| 3 | +description: >- |
| 4 | + Use this skill when working on the dubbo-go codebase, including implementing features, fixing bugs, writing tests, |
| 5 | + reviewing code, updating documentation, or routing work to a narrower dubbo-go-* domain skill. Use for cross-module |
| 6 | + questions, end-to-end flows, subsystem boundaries, or deciding whether config, runtime, protocol, registry, metadata, |
| 7 | + cluster routing, filters and observability, or tools guidance applies. |
| 8 | +--- |
| 9 | + |
| 10 | +# dubbo-go Project Guide |
| 11 | + |
| 12 | +## Project Overview |
| 13 | + |
| 14 | +dubbo-go is the Go implementation of Apache Dubbo. It is an RPC and microservice framework that provides service export and reference, registry and service discovery, protocol interoperability, cluster fault tolerance, traffic governance, configuration, metadata, metrics, tracing, and developer tools. |
| 15 | + |
| 16 | +It mainly provides: |
| 17 | +- Public client and server APIs for Go services. |
| 18 | +- Dubbo, Dubbo3, Triple, gRPC, REST, JSONRPC, and related transport support. |
| 19 | +- Registry integration with Nacos, Zookeeper, Etcd, Polaris, and application-level service discovery. |
| 20 | +- Metadata collection, metadata reporting, service name mapping, routing, load balancing, filters, metrics, tracing, and CLI or code generation tools. |
| 21 | + |
| 22 | +This repository does not own external registry servers, Dubbo Java implementation, sample applications outside this repository, or production deployment infrastructure. |
| 23 | + |
| 24 | +## Tech Stack |
| 25 | + |
| 26 | +- Language: Go, module `dubbo.apache.org/dubbo-go/v3`. |
| 27 | +- Go version: `go 1.25.0` in `go.mod`; root `Makefile` uses `GOTOOLCHAIN=go1.25.0+auto` for tests. |
| 28 | +- Build: Go modules plus nested Go modules under selected `tools/` directories. |
| 29 | +- Test: `go test`, `testify`, `gomock`, and focused package tests. |
| 30 | +- Lint and format: `go fmt`, `imports-formatter`, `go vet`, `golangci-lint`, and `make fmt` or `make lint`. |
| 31 | + |
| 32 | +Do not introduce a new framework or dependency unless the task requires it and the compatibility impact is clear. |
| 33 | + |
| 34 | +## Repository Structure |
| 35 | + |
| 36 | +- `dubbo.go`, `loader.go`: public instance and top-level load/start APIs. |
| 37 | +- `config/`, `global/`, `config_center/`, `common/config/`: config models, loading, config center, and compatibility behavior. |
| 38 | +- `client/`, `server/`, `proxy/`, `graceful_shutdown/`: runtime client/server construction, refer/export, proxy, and shutdown behavior. |
| 39 | +- `protocol/`, `remoting/`, `common/url.go`: protocol interfaces, codecs, transports, URL contract, invokers, and exporters. |
| 40 | +- `registry/`, `metadata/`: registry discovery, service discovery, metadata, reports, mapping, and revisions. |
| 41 | +- `cluster/`: directories, routers, load balancing, and cluster fault tolerance. |
| 42 | +- `filter/`, `metrics/`, `otel/`, `logger/`: filters, observability, tracing, metrics, and logging. |
| 43 | +- `tools/`: CLI, schema generator, protoc plugins, import formatter, and RPC contract scanner. |
| 44 | +- `docs/`, `doc/`: project documentation and images. |
| 45 | + |
| 46 | +## Workflow |
| 47 | + |
| 48 | +When modifying code: |
| 49 | + |
| 50 | +1. Classify the owning subsystem and load the narrower `dubbo-go-*` skill when relevant. |
| 51 | +2. Read the existing implementation and tests before editing. |
| 52 | +3. Make the smallest correct change that follows current package boundaries. |
| 53 | +4. Prefer existing abstractions, extension registries, URL params, and URL attributes over new patterns. |
| 54 | +5. Add or update focused tests for behavior changes. |
| 55 | +6. Run the most relevant validation command. |
| 56 | +7. Summarize changed files, behavior, compatibility impact, and validation result. |
| 57 | + |
| 58 | +When fixing bugs: |
| 59 | + |
| 60 | +1. Reproduce the issue or identify the failing path from tests, logs, or code. |
| 61 | +2. Find the smallest root cause. |
| 62 | +3. Make a minimal safe change. |
| 63 | +4. Add a regression test when feasible. |
| 64 | +5. Explain why the fix works and what risk remains. |
| 65 | + |
| 66 | +When reviewing code: |
| 67 | + |
| 68 | +1. Check behavior, compatibility, concurrency, error handling, generated file handling, and missing tests first. |
| 69 | +2. Ground findings in file and line references. |
| 70 | +3. Keep summary secondary to concrete risks. |
| 71 | + |
| 72 | +## Coding Guidelines |
| 73 | + |
| 74 | +- Keep changes focused and reviewable. |
| 75 | +- Follow existing package structure, naming, and extension registration patterns. |
| 76 | +- Preserve backward compatibility for public APIs, config keys, URL params, wire behavior, and generated output unless explicitly requested. |
| 77 | +- Use structured config, URL, and parser APIs instead of ad hoc string handling when available. |
| 78 | +- Avoid broad refactors during bug fixes. |
| 79 | +- Do not change unrelated files. |
| 80 | + |
| 81 | +## Testing and Validation |
| 82 | + |
| 83 | +Use the most relevant command: |
| 84 | + |
| 85 | +```bash |
| 86 | +go test ./... |
| 87 | +make test |
| 88 | +make fmt |
| 89 | +make lint |
| 90 | +make rpc-contract-check |
| 91 | +``` |
| 92 | + |
| 93 | +For focused work, prefer package-level tests first, for example: |
| 94 | + |
| 95 | +```bash |
| 96 | +go test ./config ./global ./config_center/... |
| 97 | +go test ./client ./server ./proxy ./graceful_shutdown |
| 98 | +go test ./protocol/... ./remoting/... |
| 99 | +go test ./registry/... ./metadata/... |
| 100 | +go test ./cluster/... |
| 101 | +go test ./filter/... ./metrics/... ./otel/... |
| 102 | +``` |
| 103 | + |
| 104 | +For nested tools, run tests from the owning module directory. |
| 105 | + |
| 106 | +If validation cannot be run or fails, report the command, the error, and whether it appears related to the current change. |
| 107 | + |
| 108 | +## Do Not |
| 109 | + |
| 110 | +- Do not rewrite large parts of the project without explicit instruction. |
| 111 | +- Do not introduce new dependencies or frameworks unless necessary. |
| 112 | +- Do not change public APIs, config keys, wire contracts, or generated output without documenting compatibility impact. |
| 113 | +- Do not remove or weaken tests to make validation pass. |
| 114 | +- Do not commit secrets, tokens, passwords, private keys, or private config. |
| 115 | +- Do not modify generated files manually unless the generation source is also updated or the repository already treats that file as hand-maintained. |
| 116 | +- Do not ignore existing uncommitted user changes. |
| 117 | + |
| 118 | +## Common Tasks |
| 119 | + |
| 120 | +### Choose a Domain Skill |
| 121 | + |
| 122 | +1. Map the request to the primary package. |
| 123 | +2. Use `references/architecture-map.md` when ownership is unclear. |
| 124 | +3. Load one narrower skill when possible. |
| 125 | +4. If multiple domains are involved, follow runtime flow: config, runtime, protocol, registry or metadata, cluster, filters, observability, tools. |
| 126 | + |
| 127 | +### Add a Feature |
| 128 | + |
| 129 | +1. Find the owning module and existing tests. |
| 130 | +2. Add the core behavior using existing abstractions. |
| 131 | +3. Add or update tests. |
| 132 | +4. Update documentation when public behavior changes. |
| 133 | +5. Run focused validation. |
| 134 | + |
| 135 | +### Add a Configuration Option |
| 136 | + |
| 137 | +1. Define the config key in the owning config model. |
| 138 | +2. Add default and initialization behavior. |
| 139 | +3. Wire it into the consuming module through existing options or URL params/attributes. |
| 140 | +4. Add tests for default and custom behavior. |
| 141 | +5. Update docs or schemas when relevant. |
| 142 | + |
| 143 | +### Fix a Bug |
| 144 | + |
| 145 | +1. Identify the root cause. |
| 146 | +2. Make the minimal fix. |
| 147 | +3. Add a regression test when possible. |
| 148 | +4. Verify with the narrowest relevant command. |
| 149 | + |
| 150 | +## Output Format |
| 151 | + |
| 152 | +Return the selected skill or subsystem, changed files, behavior change, compatibility impact, validation performed, and any residual risk. |
| 153 | + |
| 154 | +## Edge cases |
| 155 | + |
| 156 | +- `dubbo.Load` and `config.Load` both load configuration, but they serve different public APIs. |
| 157 | +- Registry discovery and metadata reporting are tightly coupled; use `dubbo-go-metadata` when revisions or metadata reports control behavior. |
| 158 | +- Filters wrap protocols through `protocol/protocolwrapper`; use `dubbo-go-protocol` when transport semantics change and `dubbo-go-observability-filters` when interception semantics change. |
| 159 | +- Some `tools/` subdirectories are independent Go modules. |
| 160 | + |
| 161 | +## References |
| 162 | + |
| 163 | +- Read `references/architecture-map.md` for subsystem ownership and end-to-end flow. |
| 164 | +- Read `references/project-rules.md` for compatibility, generated-file, validation, and PR guidance. |
0 commit comments