Repository navigation
Website content en overview mannual golang sdk sourcecode architecture
Go SDK 手册(版本需核对)。原文按来源版本保留;使用前请读 版本与升级。 来源:原文 · 提交
84b35ebdab20· 返回目录
Related samples:
- Quick start RPC application: dubbo-go-samples/helloworld
- Registry-based microservice application: dubbo-go-samples/registry/nacos
- Multi-protocol application: dubbo-go-samples/rpc/multi-protocols
Dubbo Go is organized around a small set of runtime concepts: an application instance, providers, consumers, protocols, registries, metadata, and governance extensions. Current applications are usually built with the API entry points in dubbo.go, server, and client, while configuration-file users still go through config.RootConfig.
| Layer | Important packages | Responsibility |
|---|---|---|
| Application instance |
dubbo.go, options.go
|
Holds application, protocol, registry, metadata, metrics, tracing, router, and shutdown options. |
| Provider API | server |
Registers service handlers, builds service options, creates invokers, and exports services. |
| Consumer API | client |
Creates clients, dials service references, creates generated or generic services, and invokes remote methods. |
| Protocol |
protocol/base, protocol/triple, protocol/dubbo, protocol/rest
|
Converts invokers into network servers on provider side and network clients on consumer side. |
| Registry and discovery |
registry, registry/protocol, registry/servicediscovery, registry/directory
|
Handles registration, subscription, service discovery, and registry-backed invocation. |
| Metadata |
metadata, metadata/report, metadata/mapping
|
Stores service definitions, service-to-application mapping, and metadata reports. |
| Governance extensions |
filter, cluster, cluster/router, cluster/loadbalance, common/extension
|
Provides filters, routing, load balancing, cluster strategies, and extension registration. |
For the current server API, a provider normally follows this path:
-
dubbo.NewInstance(...)creates an application instance and initializes global options. -
ins.NewServer(...)creates a server with application, protocol, registry, and provider options. - Generated code or user code calls
server.Register(...)orserver.RegisterService(...). - The server builds
ServiceOptions, records service metadata, and creates an invoker. -
ServiceOptions.Export()delegates to protocol export logic. - If a registry is configured,
registry/protocolcoordinates service export, registry registration, and metadata reporting.
The Triple protocol implementation exports services through protocol/triple. The application-level discovery path registers application instances and metadata through registry/servicediscovery.
A consumer normally follows this path:
-
dubbo.NewInstance(...)creates an application instance. -
ins.NewClient(...)creates a client with registry, protocol, consumer, metadata, metrics, tracing, and router options. - Generated clients call
client.DialWithInfo(...), while generic calls useclient.NewGenericService(...). - The client builds
ReferenceOptionsand initializes metadata report if needed. - Direct URLs call the target protocol directly; registry URLs go through
registry/protocol. - The registry directory receives address updates and applies routers, load balancers, and cluster logic before invoking a provider.
Many implementations are registered by Go package initialization. Importing:
import _ "dubbo.apache.org/dubbo-go/v3/imports"loads common built-in protocols, registries, filters, routers, metadata reports, tracing exporters, metrics, load balancers, and cluster strategies. Users can also import only the specific implementation packages they need.