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/config/nacos
Cluas 6fa5700c3c
chore(contrib/config): uniformly canceled by CancelFunc (#2111)
2 years ago
..
README.md fix doc (#1636) 3 years ago
config.go chore(contrib/config): uniformly canceled by CancelFunc (#2111) 2 years ago
config_test.go optimize:chan bool to chan struct{} (#1648) 3 years ago
go.mod deps: upgrade kratos version to v.2.3.1 (#2075) 3 years ago
go.sum build(deps): bump gopkg.in/yaml.v3 in /contrib/config/nacos (#2067) 3 years ago
watcher.go chore(contrib/config): uniformly canceled by CancelFunc (#2111) 2 years ago

README.md

Nacos Config

import (
	kconfig "github.com/go-kratos/kratos/v2/config"
	"github.com/nacos-group/nacos-sdk-go/clients"
	"github.com/nacos-group/nacos-sdk-go/common/constant"
)


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

cc := &constant.ClientConfig{
	NamespaceId:         "public", //namespace id
	TimeoutMs:           5000,
	NotLoadCacheAtStart: true,
	LogDir:              "/tmp/nacos/log",
	CacheDir:            "/tmp/nacos/cache",
	RotateTime:          "1h",
	MaxAge:              3,
	LogLevel:            "debug",
}

// a more graceful way to create naming client
client, err := clients.NewConfigClient(
	vo.NacosClientParam{
		ClientConfig:  cc,
		ServerConfigs: sc,
	},
)
if err != nil {
	log.Panic(err)
}