This example shows dubbo-go's dynamic configuration feature with Nacos as config-center.
dubbo: registries: demoZK: protocol: zookeeper timeout: 3s address: '127.0.0.1:2181' protocols: triple: name: tri port: 20000 provider: services: GreeterProvider: interface: com.apache.dubbo.sample.basic.IGreeter
Open https://localhost:8848/nacos/
with browser, make sure the relevant configuration is already in place in nacos.
nacosOption := config_center.WithNacos()
dataIdOption := config_center.WithDataID("dubbo-go-samples-configcenter-nacos-server")
addressOption := config_center.WithAddress("127.0.0.1:8848")
groupOption := config_center.WithGroup("dubbo")
ins, err := dubbo.NewInstance(
dubbo.WithConfigCenter(nacosOption, dataIdOption, addressOption, groupOption),
)
if err != nil {
panic(err)
}
srv, err := ins.NewServer()
if err != nil {
panic(err)
}
if err := greet.RegisterGreetServiceHandler(srv, &GreetTripleServer{}); err != nil {
panic(err)
}
if err := srv.Serve(); err != nil {
logger.Error(err)
}
$ go run ./go-client/cmd/main.go
Greet response: greeting:"hello world"