Architecture

Current Dubbo Go architecture

Related samples:

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.

Main Runtime Layers

LayerImportant packagesResponsibility
Application instancedubbo.go, options.goHolds application, protocol, registry, metadata, metrics, tracing, router, and shutdown options.
Provider APIserverRegisters service handlers, builds service options, creates invokers, and exports services.
Consumer APIclientCreates clients, dials service references, creates generated or generic services, and invokes remote methods.
Protocolprotocol/base, protocol/triple, protocol/dubbo, protocol/restConverts invokers into network servers on provider side and network clients on consumer side.
Registry and discoveryregistry, registry/protocol, registry/servicediscovery, registry/directoryHandles registration, subscription, service discovery, and registry-backed invocation.
Metadatametadata, metadata/report, metadata/mappingStores service definitions, service-to-application mapping, and metadata reports.
Governance extensionsfilter, cluster, cluster/router, cluster/loadbalance, common/extensionProvides filters, routing, load balancing, cluster strategies, and extension registration.

Provider Flow

For the current server API, a provider normally follows this path:

  1. dubbo.NewInstance(...) creates an application instance and initializes global options.
  2. ins.NewServer(...) creates a server with application, protocol, registry, and provider options.
  3. Generated code or user code calls server.Register(...) or server.RegisterService(...).
  4. The server builds ServiceOptions, records service metadata, and creates an invoker.
  5. ServiceOptions.Export() delegates to protocol export logic.
  6. If a registry is configured, registry/protocol coordinates 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.

Consumer Flow

A consumer normally follows this path:

  1. dubbo.NewInstance(...) creates an application instance.
  2. ins.NewClient(...) creates a client with registry, protocol, consumer, metadata, metrics, tracing, and router options.
  3. Generated clients call client.DialWithInfo(...), while generic calls use client.NewGenericService(...).
  4. The client builds ReferenceOptions and initializes metadata report if needed.
  5. Direct URLs call the target protocol directly; registry URLs go through registry/protocol.
  6. The registry directory receives address updates and applies routers, load balancers, and cluster logic before invoking a provider.

Extension Loading

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.