package
0.8.3
Repository: https://github.com/lalamove/konfig.git
Documentation: pkg.go.dev

# README

Consul loader

Loads config from consul KV.

Usage

Basic usage loading keys and using result as string with watcher

etcdLoader := klconsul.New(&klconsul.Config{
	Client: consulClient, // from github.com/hashicorp/consul/api package
	Keys: []Key{
		{
			Key: "foo",
		},
	},
	Watch: true,
})

Loading keys and JSON parser

consulLoader := klconsul.New(&klconsul.Config{
	Client: consulClient, // from github.com/hashicorp/consul/api package
	Keys: []Key{
		{
			Key: "foo",
			Parser: kpjson.Parser,
		},
	},
	Watch: true,
})

Strict mode

If strict mode is enabled, a key defined in the config but missing in consul will trigger an error.

# Functions

New returns a new loader with the given config.

# Structs

Config is the structure representing the config of a Loader.
Key is an Consul Key to load.
Loader is the structure of a loader.

# Interfaces

ConsulKV is an interface that consul client.KV implements.