envy

package module
v0.0.0-...-5a8583a Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2014 License: MIT Imports: 7 Imported by: 0

README

Envy

Envy provides application configuration using Etcd. It also supports simple defaults so that you don't need etcd in your development environment.

It's an easy to use drop-in replacement for shipping configuration files or environment variables during deployment.

Pull requests welcome.

Namespaces

An instance of the Envy client is initialized with a namespace, which is used to determine the path for configuration keys.

Given the namespace "myapp", the path for the key "foo" is:

/myapp/config/foo

License

Envy is released under the MIT License. See the included LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(k string) string

Get a key using the default client.

func GetAll

func GetAll() map[string]string

Get all keys using the default client

func GetSafe

func GetSafe(k string) string

Get a key using the default client.

func LoadAll

func LoadAll() error

Load all keys using the default client.

func NewDefaultClient

func NewDefaultClient(name string, machines []string)

Create a new default client with a given name and set of machines.

func SetDefaults

func SetDefaults(kv map[string]string)

Set default key/value pairs using the default client.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ns string, machines []string) *Client

Create a new client with a given namespace and array of hosts If no machine set is given we use the default of 127.0.0.1:4001

func (*Client) Get

func (c *Client) Get(k string) string

Get a key

func (*Client) GetAll

func (c *Client) GetAll() map[string]string

Get all keys

func (*Client) GetSafe

func (c *Client) GetSafe(k string) string

Get a key, panic if it doesn't exist

func (*Client) LoadAll

func (c *Client) LoadAll() (err error)

Load all key-value pairs in our namespace from etcd.

func (*Client) NewLock

func (c *Client) NewLock(name string, ttl int) *Lock

func (*Client) NewRegister

func (c *Client) NewRegister(name string) *Register

func (*Client) SetDefaults

func (c *Client) SetDefaults(kv map[string]string) (err error)

Set default key/value pairs to be used in case a key cannot be found in etcd. These will not override existing values set from another source.

type Handler

type Handler func(*Lock)

A handler is a method that consumes a lock. It is responsible for watching for loss of the lock and releasing it when done.

type Lock

type Lock struct {
	Lost chan int // Handler should read to indicate the lock was lost
	// contains filtered or unexported fields
}

func NewLock

func NewLock(name string, ttl int) *Lock

Create a new lock using the default client

func (*Lock) Release

func (l *Lock) Release()

func (*Lock) With

func (l *Lock) With(fn Handler)

Obtain a lock and run the given method

type Register

type Register struct {
	// contains filtered or unexported fields
}

func NewRegister

func NewRegister(name string) *Register

Create a new register using the default client

func (*Register) Int64

func (r *Register) Int64() (int64, error)

func (*Register) Set

func (r *Register) Set(v string) error

func (*Register) SetInt64

func (r *Register) SetInt64(i int64) error

func (*Register) String

func (r *Register) String() (string, error)

Jump to

Keyboard shortcuts

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