refactor(getty): remove legacy config dependency from remoting/getty (#3401)

* refactor(getty): remove legacy config dependency from remoting/getty

Replace all config.Get*() calls in initClient and initServer with URL
attribute reads, following the pattern already used by triple/grpc/dubbo3
protocols. The URL attributes (ProtocolConfigKey, TLSConfigKey,
ApplicationKey) are already populated by callers in server/action.go
and client/action.go, so the legacy config fallback path is redundant.

Changes:
- getty_client.go: replace config.GetApplicationConfig() / config.GetRootConfig().Protocols / config.GetRootConfig().TLSConfig with url.GetAttribute() reads. Collapse two redundant TLS blocks into one, fixing a copy-paste bug where srvConf was used instead of clientConf. Add IsClientTLSValid validation that was missing in the legacy TLS path.
- getty_server.go: same config → URL attribute migration.
- Imports: remove dubbo.apache.org/dubbo-go/v3/config and dubbo.apache.org/dubbo-go/v3, add common/config for EnsureApplicationAttribute.
- Update stale comments referencing rootConfig.

* refactor(getty): simplify protocol guard by removing ineffective GetParam check

The protocol name is stored in url.Protocol field, not in URL params.
GetParam(constant.ProtocolKey) always returns empty string in normal
flow, making the outer condition a no-op. Replace the nested check
with a direct url.GetAttribute(ProtocolConfigKey) guard.

* refactor(getty): merge redundant protocol guard and retrieval

The guard and the subsequent GetAttribute call both read the same
ProtocolConfigKey attribute. Since the guard already verified existence
and returned on miss, the second GetAttribute's !ok branch was dead
code. Merge into a single read block.

* refactor(getty): merge type assertion and TLS validity check into single if statement

* fix(getty): fail-secure on TLSConfigKey type assertion failure

When TLSConfigKey is present but not of type *global.TLSConfig, log an
error and return instead of silently skipping TLS initialization.
This prevents misconfigured TLS from being silently downgraded to
plaintext — consistent with how other protocols (gRPC, triple) handle
the same scenario.

Also add TestInitClientTLS and TestInitServerTLS to cover:
- valid TLS config → SSLEnabled/TLSBuilder set
- invalid TLS config → TLS remains disabled
- wrong TLSConfigKey type → error logged, early return
4 files changed
tree: 3989b41b3f1434ecded9852c7b89e27f6f198d3a
  1. .github/
  2. client/
  3. cluster/
  4. common/
  5. config/
  6. config_center/
  7. doc/
  8. filter/
  9. global/
  10. graceful_shutdown/
  11. imports/
  12. internal/
  13. logger/
  14. metadata/
  15. metrics/
  16. otel/
  17. protocol/
  18. proxy/
  19. registry/
  20. remoting/
  21. server/
  22. tls/
  23. tools/
  24. .asf.yaml
  25. .gitignore
  26. .gitmodules
  27. .golangci.yml
  28. .licenserc.yaml
  29. CHANGELOG.md
  30. compat.go
  31. compat_test.go
  32. CONTRIBUTING.md
  33. doc.go
  34. dubbo.go
  35. dubbo_test.go
  36. go.mod
  37. go.sum
  38. instance_options_init.go
  39. integrate_test.sh
  40. LICENSE
  41. loader.go
  42. loader_test.go
  43. Makefile
  44. NOTICE
  45. options.go
  46. README.md
  47. README_CN.md
README.md

Apache Dubbo for Golang

CI go.dev reference Go Report Card license


English | 中文

Apache Dubbo-go is a high-performance RPC and microservice framework compatible with other Dubbo language implementations. It leverages Golang's concurrency features to provide efficient service governance, including service discovery, load balancing, and traffic management. Dubbo-go supports multiple protocols, such as Dubbo, JSONRPC, Triple(gRPC-compatible), gRPC, HTTP, HTTP2, and HTTP/3 (experimental), ensuring seamless integration in heterogeneous environments.

You can visit the official website for more information.

Recent Updates

For detailed changes, refer to CHANGELOG.md.

  • 3.3.1: Optimized configuration hot-reloading with content-based caching to prevent redundant notifications. Added experimental HTTP/3 support, Apollo integration, and Triple protocol OpenAPI generation. Fixed critical race conditions in service discovery under high-concurrency.

  • 3.3.0: Introduced script routing, multi-destination conditional routing, Triple protocol keepalive and connection pooling, Nacos multi-category subscriptions, and enhancements for observability and interoperability.

Getting started

Prerequisites

  • Go 1.24 or later (recommended for compatibility with recent updates).

Installation

To install Dubbo-go, use the following command:

go get dubbo.apache.org/dubbo-go/v3@latest

Quick Example

You can learn how to develop a dubbo-go RPC application step by step in 5 minutes by following our Quick Start demo.

It's as simple as the code shown below, you define a service with Protobuf, provide your own service implementation, register it to a server, and start the server.

func (srv *GreetTripleServer) Greet(ctx context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
	resp := &greet.GreetResponse{Greeting: req.Name}
	return resp, nil
}

func main() {
	srv, _ := server.NewServer(
		server.WithServerProtocol(
			protocol.WithPort(20000),
			protocol.WithTriple(),
		),
	)

	_ := greet.RegisterGreetServiceHandler(srv, &GreetTripleServer{})

	if err := srv.Serve(); err != nil {
		logger.Error(err)
	}
}

After the server is up and running, call your service via cURL:

curl \
    --header "Content-Type: application/json" \
    --data '{"name": "Dubbo"}' \
    http://localhost:20000/greet.GreetService/Greet

Or, you can start a standard dubbo-go client to call the service:

func main() {
	cli, _ := client.NewClient(
		client.WithClientURL("127.0.0.1:20000"),
	)

	svc, _ := greet.NewGreetService(cli)

	resp, _ := svc.Greet(context.Background(), &greet.GreetRequest{Name: "hello world"})
	
	logger.Infof("Greet response: %s", resp.Greeting)
}

See the samples for detailed information on usage. Next, learn how to deploy, monitor and manage the traffic of your dubbo-go application by visiting the official website.

Features

dubbo-go-architecture

Dubbo-go provides robust service governance capabilities:

  • RPC Protocols: Triple, gRPC compatible and HTTP-friendly
  • Service Discovery: Nacos, Zookeeper, Etcd, Polaris-mesh.
  • Load Balance: Adaptive, Random, RoundRobin, LeastActive, ConsistentHash
  • Traffic Management: traffic split, timeout, rate limiting, canary release
  • Configuration: yaml file, dynamic configuration(Nacos, Apollo, Zookeeper, etc.).
  • Observability: Metrics (Prometheus), tracing (OpenTelemetry v1.21.0+ with insecure options and standardized span names), logging (with service registration lifecycle events).
  • HA Strategy: Failover, Failfast, Failsafe/Failback, Available, Broadcast, Forking.
  • Interoperability: Full compatibility with Apache Dubbo (Java) via Triple protocol generic calls, group/version wildcard matching, and TLS API redesign.

️ Tools

The tools/ directory and the dubbogo/tools repository provide several utilities to streamline your Dubbo-Go development experience.

dubbo-go-schema

A tool that provides JSON Schema for Dubbo-Go configuration files, enabling editor assistance such as completion, hints, and validation.

For usage details, see the dubbo-go-schema README.

dubbogo-cli

A command-line tool for bootstrapping, managing, and debugging Dubbo-Go applications.

protoc-gen-go-triple

A protoc plugin that generates Go client and server code for the Triple protocol from .proto definition files.

Note: This tool replaces the deprecated protoc-gen-dubbo3grpc and deprecated protoc-gen-go-triple.

For usage details, see the protoc-gen-go-triple README.

imports-formatter

A formatting tool for Dubbo-Go developers that organizes Go import blocks according to the community style guide.

For usage details, see the imports-formatter README.

variadicrpccheck

A warning-only scanner that detects exported variadic RPC contracts and prints migration guidance for cross-language scenarios.

Run make rpc-contract-check to use it locally.

Ecosystem

Documentation

Community

Contributions, issues, and discussions are welcome. Please visit CONTRIBUTING for details on submitting patches and the contribution workflow.

Contact

Join our discussion group through Ding talk or WeChat.

invite.png

User List

If you are using apache/dubbo-go and think that it helps you or want to contribute code for Dubbo-go, please add your company to the user list to let us know your needs.

See more user cases

License

Apache Dubbo-go software is licensed under the Apache License Version 2.0. See the LICENSE file for details.