consul

package module
v2.0.0-...-b3b2a34 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 7 Imported by: 19

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 New

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

Types

type Option

type Option func(o *options)

Option is consul 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