config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config provides configuration flags. These can be configured via command line flags, environment variables or via Consul.

Index

Constants

View Source
const PackageName = "config"

PackageName is the name of this package.

Variables

View Source
var ConfigFlag = DeclareString("", "config", "")

ConfigFlag is the service identifier used to get/monitor the flags from consul.

View Source
var (
	// ConsulAddressFlag is the address consul's HTTP interface listens on in
	// format <ip>:<port>.
	ConsulAddressFlag = DeclareString(
		PackageName, "consulAddress", "leverosconsul:8500")
)
View Source
var (

	// RestArgs represents the list of command line args remaining after all
	// the flags.
	RestArgs []string
)

Functions

func GetConsulClient

func GetConsulClient() *consulapi.Client

GetConsulClient returns a readily-configured consul client.

func Initialize

func Initialize()

Initialize needs to be called before any call to Get. It parses command line flags and begins monitoring of consul key holding the flags for this service.

func UploadFile

func UploadFile(filePath string, service string) error

UploadFile uploads provided config file to consul for use as flags.

Types

type FlagBool

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

FlagBool represents a boolean configuration.

func DeclareBool

func DeclareBool(pack, name string) *FlagBool

DeclareBool can be used to declare a new bool flag with a default value false.

func (*FlagBool) Get

func (flag *FlagBool) Get() bool

Get retrieves the value of flag.

type FlagDuration

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

FlagDuration represents a duration configuration.

func DeclareDuration

func DeclareDuration(
	pack, name string, defaultValue time.Duration) *FlagDuration

DeclareDuration can be used to declare a new duration flag with a default value.

func (*FlagDuration) Get

func (flag *FlagDuration) Get() time.Duration

Get retrieves the value of flag.

type FlagFloat

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

FlagFloat represents a float configuration.

func DeclareFloat

func DeclareFloat(pack, name string, defaultValue float64) *FlagFloat

DeclareFloat can be used to declare a new float flag with a default value.

func (*FlagFloat) Get

func (flag *FlagFloat) Get() float64

Get retrieves the value of flag.

type FlagInt

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

FlagInt represents an integer configuration.

func DeclareInt

func DeclareInt(pack, name string, defaultValue int) *FlagInt

DeclareInt can be used to declare a new int flag with a default value.

func (*FlagInt) Get

func (flag *FlagInt) Get() int

Get retrieves the value of flag.

type FlagString

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

FlagString represents a string configuration.

func DeclareString

func DeclareString(pack, name, defaultValue string) *FlagString

DeclareString can be used to declare a new string flag with a default value.

func (*FlagString) Get

func (flag *FlagString) Get() string

Get retrieves the value of flag.

Jump to

Keyboard shortcuts

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