leveros: github.com/leveros/leveros/config Index | Files

package config

import "github.com/leveros/leveros/config"

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

Index

Package Files

config.go consul.go

Constants

const PackageName = "config"

PackageName is the name of this package.

Variables

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

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

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

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

func GetConsulClient Uses

func GetConsulClient() *consulapi.Client

GetConsulClient returns a readily-configured consul client.

func Initialize Uses

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 Uses

func UploadFile(filePath string, service string) error

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

type FlagBool Uses

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

FlagBool represents a boolean configuration.

func DeclareBool Uses

func DeclareBool(pack, name string) *FlagBool

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

func (*FlagBool) Get Uses

func (flag *FlagBool) Get() bool

Get retrieves the value of flag.

type FlagDuration Uses

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

FlagDuration represents a duration configuration.

func DeclareDuration Uses

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 Uses

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

Get retrieves the value of flag.

type FlagFloat Uses

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

FlagFloat represents a float configuration.

func DeclareFloat Uses

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 Uses

func (flag *FlagFloat) Get() float64

Get retrieves the value of flag.

type FlagInt Uses

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

FlagInt represents an integer configuration.

func DeclareInt Uses

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 Uses

func (flag *FlagInt) Get() int

Get retrieves the value of flag.

type FlagString Uses

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

FlagString represents a string configuration.

func DeclareString Uses

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

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

func (*FlagString) Get Uses

func (flag *FlagString) Get() string

Get retrieves the value of flag.

Package config imports 12 packages (graph) and is imported by 70 packages. Updated 2016-07-23. Refresh now. Tools for package owners.