consul

package
v0.0.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 9 Imported by: 0

README

Consul Config

import (
    "github.com/hashicorp/consul/api"

    "github.com/go-kratos/kratos/contrib/config/consul/v2"
)

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))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(uri *url.URL, v interface{}) (config.Config, error)

func New

func New(client *api.Client, opts ...Option) (config.Source, error)

Types

type Option

type Option func(o *options)

Option is etcd config option.

func WithContext

func WithContext(ctx context.Context) Option

WithContext with registry context.

func WithPath

func WithPath(p string) Option

WithPath is config path

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL