You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/contrib/registry/nacos
包子 7e0045cd0f
fix: nacos a vulnerable dependency was referenced (#1639)
3 years ago
..
README.md test: add nacos test (#1603) 3 years ago
go.mod fix: nacos a vulnerable dependency was referenced (#1639) 3 years ago
go.sum fix: nacos a vulnerable dependency was referenced (#1639) 3 years ago
registry.go fix: k8s nacos and zookeeper registry lint (#1599) 3 years ago
registry_test.go fix: nacos registry test data race (#1613) 3 years ago
watcher.go test: add nacos test (#1603) 3 years ago

README.md

Nacos Registry

import (
		"github.com/go-kratos/kratos/v2"
		"github.com/go-kratos/kratos/v2/transport/grpc"
		
		"github.com/nacos-group/nacos-sdk-go/clients"
		"github.com/nacos-group/nacos-sdk-go/common/constant"
    	"github.com/nacos-group/nacos-sdk-go/vo"
)

sc := []constant.ServerConfig{
	*constant.NewServerConfig("127.0.0.1", 8848),
}

cc := constant.ClientConfig{
	NamespaceId:         "public",
	TimeoutMs:           5000,
}

client, err := clients.NewNamingClient(
	vo.NacosClientParam{
		ClientConfig:  &cc,
		ServerConfigs: sc,
	},
)

if err != nil {
	log.Panic(err)
}

r := nacos.New(client)

// server
app := kratos.New(
	kratos.Name("helloworld"),
	kratos.Registrar(r),
)
if err := app.Run(); err != nil {
	log.Fatal(err)
}

// client
conn, err := grpc.DialInsecure(
	context.Background(),
	grpc.WithEndpoint("discovery:///helloworld"),
	grpc.WithDiscovery(r),
)