phlag

package module
v0.0.0-...-a6700d4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2014 License: BSD-2-Clause Imports: 10 Imported by: 0

README

phlag

Command line configuration library with etcd fallback.

Configuration

Etcd

By default phlag uses the etcd endpoint as define int he ETCD_ENDPOINT environment variable. In order to use a different variable or your own etcd client use one of the alternative methods in the phlag package.

Logging

Phlag logs to the sdk logger by default, if you prefer a different logging framework overwrite phlag.Logger with the implementation you prefer.

Usage

import (
	"github.com/ProductHealth/phlag"
)

type MyConfiguration struct {
    SomeField       string      `phlag:"somefield"`
}

func ReadConfiguration() *Configuration {
	p, _ := phlag.New("/company.com/services/fooservice/params/%v")
	var config = new(Configuration)
	p.Resolve(config)
	return config
}

phlag will attempt to find a command line argument 'somefield', if this is not present phlag will query etcd using the given template.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger func(string, ...interface{}) = log.Printf

Logger function, replace by your preferred implementation

Functions

This section is empty.

Types

type Phlag

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

func New

func New(etcdPathTemplate string) (*Phlag, error)

func (*Phlag) Get

func (e *Phlag) Get(name, etcdPath string) *string

Get the named parameter from either the cli or etcd

func (*Phlag) Resolve

func (e *Phlag) Resolve(target interface{})

Jump to

Keyboard shortcuts

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