etcdconfig

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2014 License: Apache-2.0, BSD-3-Clause, Zlib Imports: 4 Imported by: 2

Documentation

Overview

Package etcdconfig provides a method for programs to scrape configuration from etcd as well as continously update it. It is suggested that any program using this package as a primary configuration source also have a "seed" option or similar to ensure that etcd does not have any missing keys from the first launch.

Currently etcdconfig supports strings, string->string maps and boolean variables from etcd. More will be added as time goes on. Usage is very simple:

type Config struct {
	Foo string            `etcd:"/test/foo"`
	Bar bool              `etcd:"/test/bar"`
	Baz map[string]string `etcd:"/test/baz"`
}

Demarshal(etcd, someStruct)

A string will always have its value copied verbatim.

A boolean merely checks for the presence or absense of a key.

With maps, the directory tree will be recursively walked and all subdirectories and their keys will be added as-is.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Demarshal

func Demarshal(etcd *etcd.Client, target interface{}) (err error)

Demarshal takes an etcd client and a an anonymous interface to seed with values from etcd. This will throw an error if there is an exceptional error in the etcd client or you are invoking this incorrectly with maps. Any missing keys in etcd will be filled in with blank strings.

func SetMapOffDir

func SetMapOffDir(parent *etcd.Node, target *reflect.Value, tack string)

SetMapOffDir sets a map based off of an etcd directory and its contents.

func Subscribe

func Subscribe(e *etcd.Client, target interface{}, prefix string) (err error)

Subscribe continuously updates the target structure with data from etcd as it is changed. This is ideal for things such as configuration or a list of keys for authentication.

Types

This section is empty.

Jump to

Keyboard shortcuts

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