consul

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 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{}, format string) (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 WithFormat added in v0.1.1

func WithFormat(f string) Option

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