Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to support nacos cluster mode? #4241

Open
ZUCCzwp opened this issue Jul 11, 2024 · 1 comment
Open

How to support nacos cluster mode? #4241

ZUCCzwp opened this issue Jul 11, 2024 · 1 comment

Comments

@ZUCCzwp
Copy link

ZUCCzwp commented Jul 11, 2024

https://github.com/zeromicro/zero-contrib/tree/main/zrpc/registry/nacos Currently, nacos only supports single address configuration, not nacos cluster configuration.
If i want to support cluster mode, how to configure it?

@ljluestc
Copy link

// Example of how the configuration might look in Go for zrpc with Nacos cluster
import (
    "github.com/zeromicro/zero-contrib/zrpc/registry/nacos"
)

func main() {
    // Assuming we have a list of Nacos server addresses
    nacosServers := []string{
        "192.168.1.1:8848",
        "192.168.1.2:8848",
        "192.168.1.3:8848",
    }

    // Configuration for Nacos registry in cluster mode
    nacosConf := nacos.NacosConfig{
        Endpoint: "nacos-cluster.com", // This could be a domain name pointing to an SLB
        NamespaceId: "public",
        ClusterName: "cluster-1",
        ServiceName: "my-service",
        GroupName:   "DEFAULT_GROUP",
        // Assuming there's a way to pass multiple server addresses
        ServerAddrs: nacosServers,
    }

    // Initialize the registry with the cluster configuration
    registry, err := nacos.NewNacosRegistry(nacosConf)
    if err != nil {
        panic(err)
    }

    // Use this registry in your zrpc server setup
    // ... (rest of the server setup code)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants