consul

package module
v0.0.0-...-0a38125 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 7 Imported by: 0

README

Consul Config

import (
    "github.com/fengleng/mars/contrib/config/consul"
    "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 mars 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 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