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/consul
包子 7fe194ead4
deps: uprade kratos version to v2.1.4 (#1749)
3 years ago
..
README.md test: add nacos test (#1603) 3 years ago
config.go feat(contrib/config): use key file extension as format & config load log (#1619) 3 years ago
config_test.go feat(contrib/config): use key file extension as format & config load log (#1619) 3 years ago
go.mod deps: uprade kratos version to v2.1.4 (#1749) 3 years ago
go.sum feat: upgrade grpc version to 1.42.0 (#1626) 3 years ago
watcher.go feat: Add consul kv config provider (#1499) 3 years ago

README.md

Consul 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.NewNamingClient(
	vo.NacosClientParam{
		ClientConfig:  cc,
		ServerConfigs: sc,
	},
)
if err != nil {
	log.Panic(err)
}