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
dependabot[bot] 377356d04d
build(deps): bump github.com/hashicorp/consul/api (#2211)
2 years ago
..
README.md fix: change consul config docs (#1784) 3 years ago
config.go fix: delete redundant type conversion (#1977) 3 years ago
config_test.go test(contrib/config/consul): add unit test for contrib/config/consul (#2179) 3 years ago
go.mod build(deps): bump github.com/hashicorp/consul/api (#2211) 2 years ago
go.sum build(deps): bump github.com/hashicorp/consul/api (#2211) 2 years ago
watcher.go chore(contrib/config): uniformly canceled by CancelFunc (#2111) 3 years ago

README.md

Consul Config

import (
    "github.com/go-kratos/kratos/contrib/config/consul/v2"
    "github.com/hashicorp/consul/api"
)
func main() {

    consulClient, err := api.NewClient(&api.Config{
    Address: "127.0.0.1:8500",
    })
    if err != nil {
        panic(err)
    }
    cs, err := consul.New(consulClient, consul.WithPath("app/cart/configs/"))
    //consul中需要标注文件后缀,kratos读取配置需要适配文件后缀
    //The file suffix needs to be marked, and kratos needs to adapt the file suffix to read the configuration.
    if err != nil {
        panic(err)
    }
    c := config.New(config.WithSource(cs))
}