config

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

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

Go to latest
Published: Sep 25, 2020 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

config

config

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConfigFile   string
	ConfigString string

	Configuration
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(opts ...Option) *Config

func (*Config) String

func (p *Config) String() string

func (*Config) WithFallback

func (p *Config) WithFallback(fallback Configuration) Configuration

type Configuration

type Configuration interface {
	GetBoolean(path string, defaultVal ...bool) bool
	GetByteSize(path string) *big.Int
	GetInt32(path string, defaultVal ...int32) int32
	GetInt64(path string, defaultVal ...int64) int64
	GetString(path string, defaultVal ...string) string
	GetFloat32(path string, defaultVal ...float32) float32
	GetFloat64(path string, defaultVal ...float64) float64
	GetTimeDuration(path string, defaultVal ...time.Duration) time.Duration
	GetTimeDurationInfiniteNotAllowed(path string, defaultVal ...time.Duration) time.Duration
	GetBooleanList(path string) []bool
	GetFloat32List(path string) []float32
	GetFloat64List(path string) []float64
	GetInt32List(path string) []int32
	GetInt64List(path string) []int64
	GetByteList(path string) []byte
	GetStringList(path string) []string
	GetConfig(path string) Configuration
	WithFallback(fallback Configuration) Configuration
	HasPath(path string) bool
	Keys() []string
	IsEmpty() bool
	IsObject(path string) bool
	IsArray(path string) bool

	String() string
}

func NewHOCONConfiguration

func NewHOCONConfiguration(conf *configuration.Config) Configuration

func NewViperConfiguration

func NewViperConfiguration(conf *viper.Viper) Configuration

type ConfigurationProvider

type ConfigurationProvider interface {
	LoadConfig(filename string) Configuration
	ParseString(cfgStr string) Configuration
}

type HOCONConfigProvider

type HOCONConfigProvider struct {
}

func (*HOCONConfigProvider) LoadConfig

func (p *HOCONConfigProvider) LoadConfig(filename string) Configuration

func (*HOCONConfigProvider) ParseString

func (p *HOCONConfigProvider) ParseString(cfgStr string) Configuration

type HOCONConfiguration

type HOCONConfiguration struct {
	*configuration.Config
}

func (*HOCONConfiguration) GetBoolean

func (p *HOCONConfiguration) GetBoolean(path string, defaultVal ...bool) bool

func (*HOCONConfiguration) GetBooleanList

func (p *HOCONConfiguration) GetBooleanList(path string) []bool

func (*HOCONConfiguration) GetByteList

func (p *HOCONConfiguration) GetByteList(path string) []byte

func (*HOCONConfiguration) GetByteSize

func (p *HOCONConfiguration) GetByteSize(path string) *big.Int

func (*HOCONConfiguration) GetConfig

func (p *HOCONConfiguration) GetConfig(path string) Configuration

func (*HOCONConfiguration) GetFloat32

func (p *HOCONConfiguration) GetFloat32(path string, defaultVal ...float32) float32

func (*HOCONConfiguration) GetFloat32List

func (p *HOCONConfiguration) GetFloat32List(path string) []float32

func (*HOCONConfiguration) GetFloat64

func (p *HOCONConfiguration) GetFloat64(path string, defaultVal ...float64) float64

func (*HOCONConfiguration) GetFloat64List

func (p *HOCONConfiguration) GetFloat64List(path string) []float64

func (*HOCONConfiguration) GetInt32

func (p *HOCONConfiguration) GetInt32(path string, defaultVal ...int32) int32

func (*HOCONConfiguration) GetInt32List

func (p *HOCONConfiguration) GetInt32List(path string) []int32

func (*HOCONConfiguration) GetInt64

func (p *HOCONConfiguration) GetInt64(path string, defaultVal ...int64) int64

func (*HOCONConfiguration) GetInt64List

func (p *HOCONConfiguration) GetInt64List(path string) []int64

func (*HOCONConfiguration) GetString

func (p *HOCONConfiguration) GetString(path string, defaultVal ...string) string

func (*HOCONConfiguration) GetStringList

func (p *HOCONConfiguration) GetStringList(path string) []string

func (*HOCONConfiguration) GetTimeDuration

func (p *HOCONConfiguration) GetTimeDuration(path string, defaultVal ...time.Duration) time.Duration

func (*HOCONConfiguration) GetTimeDurationInfiniteNotAllowed

func (p *HOCONConfiguration) GetTimeDurationInfiniteNotAllowed(path string, defaultVal ...time.Duration) time.Duration

func (*HOCONConfiguration) HasPath

func (p *HOCONConfiguration) HasPath(path string) bool

func (*HOCONConfiguration) IsArray

func (p *HOCONConfiguration) IsArray(path string) bool

func (*HOCONConfiguration) IsEmpty

func (p *HOCONConfiguration) IsEmpty() bool

func (*HOCONConfiguration) IsObject

func (p *HOCONConfiguration) IsObject(path string) bool

func (*HOCONConfiguration) Keys

func (p *HOCONConfiguration) Keys() []string

func (*HOCONConfiguration) String

func (p *HOCONConfiguration) String() string

func (*HOCONConfiguration) WithFallback

func (p *HOCONConfiguration) WithFallback(fallback Configuration) Configuration

type Option

type Option func(*Config)

func ConfigFile

func ConfigFile(fn string) Option

func ConfigProvider

func ConfigProvider(provider ConfigurationProvider) Option

func ConfigString

func ConfigString(str string) Option

func WithConfig

func WithConfig(conf Configuration) Option

type ViperConfigProvider

type ViperConfigProvider struct {
}

func (*ViperConfigProvider) LoadConfig

func (p *ViperConfigProvider) LoadConfig(name string) Configuration

func (*ViperConfigProvider) ParseString

func (p *ViperConfigProvider) ParseString(cfgStr string) Configuration

type ViperConfiguration

type ViperConfiguration struct {
	*viper.Viper
}

func (*ViperConfiguration) GetBoolean

func (p *ViperConfiguration) GetBoolean(path string, defaultVal ...bool) bool

func (*ViperConfiguration) GetBooleanList

func (p *ViperConfiguration) GetBooleanList(path string) []bool

func (*ViperConfiguration) GetByteList

func (p *ViperConfiguration) GetByteList(path string) []byte

func (*ViperConfiguration) GetByteSize

func (p *ViperConfiguration) GetByteSize(path string) *big.Int

func (*ViperConfiguration) GetConfig

func (p *ViperConfiguration) GetConfig(path string) Configuration

func (*ViperConfiguration) GetFloat32

func (p *ViperConfiguration) GetFloat32(path string, defaultVal ...float32) float32

func (*ViperConfiguration) GetFloat32List

func (p *ViperConfiguration) GetFloat32List(path string) []float32

func (*ViperConfiguration) GetFloat64

func (p *ViperConfiguration) GetFloat64(path string, defaultVal ...float64) float64

func (*ViperConfiguration) GetFloat64List

func (p *ViperConfiguration) GetFloat64List(path string) []float64

func (*ViperConfiguration) GetInt32

func (p *ViperConfiguration) GetInt32(path string, defaultVal ...int32) int32

func (*ViperConfiguration) GetInt32List

func (p *ViperConfiguration) GetInt32List(path string) []int32

func (*ViperConfiguration) GetInt64

func (p *ViperConfiguration) GetInt64(path string, defaultVal ...int64) int64

func (*ViperConfiguration) GetInt64List

func (p *ViperConfiguration) GetInt64List(path string) []int64

func (*ViperConfiguration) GetString

func (p *ViperConfiguration) GetString(path string, defaultVal ...string) string

func (*ViperConfiguration) GetStringList

func (p *ViperConfiguration) GetStringList(path string) []string

func (*ViperConfiguration) GetTimeDuration

func (p *ViperConfiguration) GetTimeDuration(path string, defaultVal ...time.Duration) time.Duration

func (*ViperConfiguration) GetTimeDurationInfiniteNotAllowed

func (p *ViperConfiguration) GetTimeDurationInfiniteNotAllowed(path string, defaultVal ...time.Duration) time.Duration

func (*ViperConfiguration) HasPath

func (p *ViperConfiguration) HasPath(path string) bool

func (*ViperConfiguration) IsArray

func (p *ViperConfiguration) IsArray(path string) bool

func (*ViperConfiguration) IsEmpty

func (p *ViperConfiguration) IsEmpty() bool

func (*ViperConfiguration) IsObject

func (p *ViperConfiguration) IsObject(path string) bool

func (*ViperConfiguration) Keys

func (p *ViperConfiguration) Keys() []string

func (*ViperConfiguration) String

func (p *ViperConfiguration) String() string

func (*ViperConfiguration) WithFallback

func (p *ViperConfiguration) WithFallback(fallback Configuration) Configuration

Jump to

Keyboard shortcuts

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