Cloud Native 11 min read

How to Seamlessly Integrate Polaris Service Governance with dubbogo Go RPC

This guide explains why and how to combine Tencent's open‑source Polaris service‑governance platform with the high‑performance dubbogo Go RPC framework, covering architecture, registration, discovery, dynamic routing and rate‑limiting, complete with configuration snippets and practical code examples.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How to Seamlessly Integrate Polaris Service Governance with dubbogo Go RPC

Background

Polaris is an open‑source cloud‑native service‑governance platform that provides service management, traffic control, configuration, fault tolerance and observability for distributed and microservice architectures. dubbogo is a high‑performance Go RPC framework in the Dubbo ecosystem, offering native service registration, discovery and extensibility.

Why Integrate

Microservice projects typically deploy multiple components (e.g., Nacos, Sentinel, Prometheus, SkyWalking) to address different governance concerns, which leads to fragmented management and poor data correlation. Polaris offers a unified, multi‑language governance plane, allowing Go developers to obtain service registration, discovery, dynamic routing and rate limiting through a single configuration without code changes.

Technical Architecture

Polaris provides language‑agnostic SDKs (data‑plane). dubbogo can inject Polaris capabilities via its Extension mechanism. The integration points are:

Registry/ServiceDiscovery extension – maps Polaris service registration and discovery to dubbogo.

PriorityRouter extension – maps Polaris dynamic routing to dubbogo.

TpsLimiter extension – maps Polaris rate‑limiting to dubbogo.

Each extension implements a dubbogo hook that delegates the governance logic to Polaris.

How to Integrate

Add the polaris-go SDK as a dependency (e.g., go get github.com/polarismesh/polaris-go).

Enable the Polaris extension in dubbogo.yaml by setting protocol: polaris and providing the Polaris server address.

No additional code changes are required for basic registration and discovery; the SDK injects the necessary logic at runtime.

Service Registration

Polaris implements dubbogo’s native registration extension. Add a Polaris registry entry to dubbogo.yaml:

dubbo:
  registries:
    polaris-1:
      protocol: polaris
      address: ${POLARIS_IP}:8091

After restarting the service, instances appear in the Polaris console.

Service Discovery

When a dubbogo client invokes a service, the Polaris Registry extension returns the instance list, which dubbogo converts to invokers. No code changes are needed beyond the YAML configuration.

Dynamic Routing

Polaris can route requests based on Dubbo request attributes (e.g., user tags). Define a routing rule in Polaris (e.g., route uid=user-1 to version 2.0.0, others to 1.0.0). Pass the attribute via the Dubbo context:

func (s *Service) GetUser(uid string) {
    atta := map[string]interface{}{ "uid": uid }
    ctx := context.WithValue(context.Background(), constant.DubboCtxKey("attachment"), atta)
    // invoke service using ctx
}

Access Rate Limiting

Polaris’ TpsLimiter can limit calls based on request content, e.g., limit GetUser calls where Name="Alex" to 10 requests/s. Enable the limiter in dubbogo.yaml:

dubbo:
  provider:
    services:
      UserProvider:
        interface: org.apache.dubbo.UserProvider.Test
        tps.limiter: polaris-limit

Sample test code demonstrates success/failure counts after the limiter is applied:

func (s *Service) Test() {
    var successCount, failCount int64
    for i := 0; i < 10; i++ {
        time.Sleep(50 * time.Millisecond)
        if user, err := userProvider.GetUser(context.TODO(), &User{Name: "Alex03"}); err != nil {
            failCount++
        } else {
            successCount++
            _ = user
        }
    }
    logger.Infof("successCount=%v, failCount=%v", successCount, failCount)
}

Future Plans

PolarisMesh will extend the integration with circuit breaking, node isolation, observability and configuration‑center capabilities, further consolidating one‑stop governance for dubbogo.

References

Polaris project: https://github.com/polarismesh/polaris

dubbogo project: https://github.com/apache/dubbo-go

dubbogo‑Polaris example: https://github.com/apache/dubbo-go-samples/tree/master/polaris

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

MicroservicesGoService MeshPolarisdubbogo
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.