gconf

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

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathDelimiter  = "/"
	RootPath       = "/"
	ArrayDelimiter = "$"
)

Variables

This section is empty.

Functions

func BooleanToString

func BooleanToString(val bool) string

func ByteToString

func ByteToString(val byte) string

func FindChildKeys

func FindChildKeys(basePath string, keys []string) []string

func Float32ToString

func Float32ToString(val float32) string

func Float64ToString

func Float64ToString(val float64) string

func GetArrayIndex

func GetArrayIndex(idx int) string

func GetArrayIndexPath

func GetArrayIndexPath(path string, idx int) string

func GetParentPath

func GetParentPath(path string) string

func GetPaths

func GetPaths(key string) []string

func GetSectionKey

func GetSectionKey(path string) string

func HasPathInKey

func HasPathInKey(path, key string) bool

func Int32ToString

func Int32ToString(val int) string

func Int64ToString

func Int64ToString(val int64) string

func IsArrayIndex

func IsArrayIndex(path string) bool

func IsArrayPath

func IsArrayPath(path string, keys []string) bool

func LengthOfArrayPath

func LengthOfArrayPath(path string, keys []string) int

func PathCombine

func PathCombine(path ...string) string

func StringToBoolean

func StringToBoolean(val string) (bool, error)

func StringToByte

func StringToByte(val string) (byte, error)

func StringToFloat32

func StringToFloat32(val string) (float32, error)

func StringToFloat64

func StringToFloat64(val string) (float64, error)

func StringToInt32

func StringToInt32(val string) (int, error)

func StringToInt64

func StringToInt64(val string) (int64, error)

func StringToUint32

func StringToUint32(val string) (uint, error)

func StringToUint64

func StringToUint64(val string) (uint64, error)

func Uint32ToString

func Uint32ToString(val uint32) string

func Uint64ToString

func Uint64ToString(val uint64) string

Types

type Change

type Change struct {
	KeyName string
	Mode    ChangeMode
	Prev    interface{}
	Current interface{}
}

func (*Change) String

func (c *Change) String() string

type ChangeMode

type ChangeMode int
const (
	Created ChangeMode = iota
	Removed
	Modified
)

type ChangeToken

type ChangeToken interface {
	SetCallback(callback func())
	HasChanged() bool
	SetAsChanged()
	OnChanged()
}

func NewChangeToken

func NewChangeToken() ChangeToken

type Conf

type Conf interface {
	ConfBase
	GetBoolean(key string) (bool, error)
	GetByte(key string) (byte, error)
	GetInt(key string) (int, error)
	GetInt64(key string) (int64, error)
	GetUint(key string) (uint, error)
	GetUint64(key string) (uint64, error)
	GetFloat32(key string) (float32, error)
	GetFloat64(key string) (float64, error)
	GetComplex64(key string) (complex64, error)
	GetComplex128(key string) (complex128, error)
	GetString(key string) (string, error)
	TryGet(key string, defaultValue interface{}) interface{}
	TryGetBoolean(key string, defaultValue bool) bool
	TryGetByte(key string, defaultValue byte) byte
	TryGetInt(key string, defaultValue int) int
	TryGetInt64(key string, defaultValue int64) int64
	TryGetUint(key string, defaultValue uint) uint
	TryGetUint64(key string, defaultValue uint64) uint64
	TryGetFloat32(key string, defaultValue float32) float32
	TryGetFloat64(key string, defaultValue float64) float64
	TryGetComplex64(key string, defaultValue complex64) complex64
	TryGetComplex128(key string, defaultValue complex128) complex128
	TryGetString(key string, defaultValue string) string
	GetSection(key string) ConfSection
	GetArraySection(key string) ConfArraySection
}

type ConfArraySection

type ConfArraySection interface {
	Conf
	Length() int
	GetIndexSection(idx int) ConfSection
}

func NewConfArraySection

func NewConfArraySection(root ConfRoot, path string) ConfArraySection

type ConfBase

type ConfBase interface {
	GetPath() string
	Get(key string) interface{}
	Set(key string, value interface{}) error
	ContainKey(key string) bool
	Keys() []string
	Values() []interface{}
	ToKeyValuePairs() []KeyValuePair
	IsEmpty() bool
	IsArray() bool
}

type ConfBuilder

type ConfBuilder interface {
	Add(confSource ConfSource) ConfBuilder
	GetSources() []ConfSource
	Build() (ConfRoot, error)
}

func NewConfBuilder

func NewConfBuilder() ConfBuilder

type ConfChanges

type ConfChanges interface {
	GetNumOfChanges() int
	GetChanges() []Change
}

func CalcConfChanges

func CalcConfChanges(current map[string]interface{}, prev map[string]interface{}) ConfChanges

func EmptyConfChanges

func EmptyConfChanges() ConfChanges

type ConfProvider

type ConfProvider interface {
	Conf
	Load() error
	Reload() error
	Dispose()
	GetChangeToken() ChangeToken
}

func NewConfProvider

func NewConfProvider(source ConfSource) (ConfProvider, error)

type ConfRoot

type ConfRoot interface {
	Conf
	Reload() error
	Dispose()
}

type ConfSection

type ConfSection interface {
	Conf
}

func NewConfSection

func NewConfSection(root ConfRoot, path string) ConfSection

type ConfSource

type ConfSource interface {
	Build(confBuilder ConfBuilder) (ConfProvider, error)
	Load() (map[string]interface{}, error)
}

type EnvConfSource

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

func NewEnvConfSource

func NewEnvConfSource() *EnvConfSource

func (*EnvConfSource) Build

func (s *EnvConfSource) Build(builder ConfBuilder) (ConfProvider, error)

func (*EnvConfSource) Load

func (s *EnvConfSource) Load() (map[string]interface{}, error)

func (*EnvConfSource) SetPrefix

func (s *EnvConfSource) SetPrefix(prefix string) *EnvConfSource

type FileConfProvider

type FileConfProvider interface {
	ConfProvider
	OnChanged()
}

func NewFileConfProvider

func NewFileConfProvider(source FileConfSource) (FileConfProvider, error)

type FileConfSource

type FileConfSource interface {
	ConfSource
	SetEndureIfNotExist(bool) FileConfSource
	SetOnConfChangedCallback(func(ConfChanges)) FileConfSource
	GetOnConfChangedCallback() func(ConfChanges)
	GetFileInfo() FileInfo
	GetFilePath() string
	IsEndureIfNotExist() bool
	IsFileExist() bool
}

type FileInfo

type FileInfo interface {
	Exists() bool
	IsDirectory() bool
	LastModified() time.Time
	GetLength() int64
	GetName() string
	GetPhysicalPath() string
	ReadAll() ([]byte, error)
}

func NewFileInfo

func NewFileInfo(filePath string) FileInfo

type JsonConfSource

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

func NewJsonConfSource

func NewJsonConfSource(jsonMessage []byte) *JsonConfSource

func (*JsonConfSource) Build

func (s *JsonConfSource) Build(confBuilder ConfBuilder) (ConfProvider, error)

func (*JsonConfSource) Load

func (s *JsonConfSource) Load() (map[string]interface{}, error)

type JsonFileConfSource

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

func NewJsonFileConfSource

func NewJsonFileConfSource(path string) *JsonFileConfSource

func (*JsonFileConfSource) Build

func (s *JsonFileConfSource) Build(builder ConfBuilder) (ConfProvider, error)

func (*JsonFileConfSource) GetFileInfo

func (s *JsonFileConfSource) GetFileInfo() FileInfo

func (*JsonFileConfSource) GetFilePath

func (s *JsonFileConfSource) GetFilePath() string

func (*JsonFileConfSource) GetOnConfChangedCallback

func (s *JsonFileConfSource) GetOnConfChangedCallback() func(ConfChanges)

func (*JsonFileConfSource) IsEndureIfNotExist

func (s *JsonFileConfSource) IsEndureIfNotExist() bool

func (*JsonFileConfSource) IsFileExist

func (s *JsonFileConfSource) IsFileExist() bool

func (*JsonFileConfSource) Load

func (s *JsonFileConfSource) Load() (map[string]interface{}, error)

func (*JsonFileConfSource) SetEndureIfNotExist

func (s *JsonFileConfSource) SetEndureIfNotExist(endureIfNotExist bool) FileConfSource

func (*JsonFileConfSource) SetOnConfChangedCallback

func (s *JsonFileConfSource) SetOnConfChangedCallback(onConfChangedCallback func(ConfChanges)) FileConfSource

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value interface{}
}

func FindChildPairs

func FindChildPairs(basePath string, pairs []KeyValuePair) []KeyValuePair

type MemConfSource

type MemConfSource struct {
}

func NewMapConfSource

func NewMapConfSource(conf map[string]interface{}) *MemConfSource

func (*MemConfSource) Build

func (s *MemConfSource) Build(builder ConfBuilder) (ConfProvider, error)

func (*MemConfSource) Load

func (s *MemConfSource) Load() (map[string]interface{}, error)

type StringSplitter

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

func NewStringSplitter

func NewStringSplitter(str string) StringSplitter

func (StringSplitter) Split

func (s StringSplitter) Split(sep string, removeIfEmpty bool) []string

type TomlConfSource

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

func NewTomlConfSource

func NewTomlConfSource(tomlMessage []byte) *TomlConfSource

func (*TomlConfSource) Build

func (s *TomlConfSource) Build(confBuilder ConfBuilder) (ConfProvider, error)

func (*TomlConfSource) Load

func (s *TomlConfSource) Load() (map[string]interface{}, error)

type TomlFileConfSource

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

func NewTomlFileConfSource

func NewTomlFileConfSource(path string) *TomlFileConfSource

func (*TomlFileConfSource) Build

func (s *TomlFileConfSource) Build(builder ConfBuilder) (ConfProvider, error)

func (*TomlFileConfSource) GetFileInfo

func (s *TomlFileConfSource) GetFileInfo() FileInfo

func (*TomlFileConfSource) GetFilePath

func (s *TomlFileConfSource) GetFilePath() string

func (*TomlFileConfSource) GetOnConfChangedCallback

func (s *TomlFileConfSource) GetOnConfChangedCallback() func(ConfChanges)

func (*TomlFileConfSource) IsEndureIfNotExist

func (s *TomlFileConfSource) IsEndureIfNotExist() bool

func (*TomlFileConfSource) IsFileExist

func (s *TomlFileConfSource) IsFileExist() bool

func (*TomlFileConfSource) Load

func (s *TomlFileConfSource) Load() (map[string]interface{}, error)

func (*TomlFileConfSource) SetEndureIfNotExist

func (s *TomlFileConfSource) SetEndureIfNotExist(endureIfNotExist bool) FileConfSource

func (*TomlFileConfSource) SetOnConfChangedCallback

func (s *TomlFileConfSource) SetOnConfChangedCallback(onConfChangedCallback func(ConfChanges)) FileConfSource

type TypeConverter

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

func NewTypeConverter

func NewTypeConverter(confBase ConfBase) TypeConverter

func (*TypeConverter) GetBoolean

func (t *TypeConverter) GetBoolean(key string) (bool, error)

func (*TypeConverter) GetByte

func (t *TypeConverter) GetByte(key string) (byte, error)

func (*TypeConverter) GetComplex128

func (t *TypeConverter) GetComplex128(key string) (complex128, error)

func (*TypeConverter) GetComplex64

func (t *TypeConverter) GetComplex64(key string) (complex64, error)

func (*TypeConverter) GetFloat32

func (t *TypeConverter) GetFloat32(key string) (float32, error)

func (*TypeConverter) GetFloat64

func (t *TypeConverter) GetFloat64(key string) (float64, error)

func (*TypeConverter) GetInt

func (t *TypeConverter) GetInt(key string) (int, error)

func (*TypeConverter) GetInt64

func (t *TypeConverter) GetInt64(key string) (int64, error)

func (*TypeConverter) GetString

func (t *TypeConverter) GetString(key string) (string, error)

func (*TypeConverter) GetUint

func (t *TypeConverter) GetUint(key string) (uint, error)

func (*TypeConverter) GetUint64

func (t *TypeConverter) GetUint64(key string) (uint64, error)

func (*TypeConverter) TryGetBoolean

func (t *TypeConverter) TryGetBoolean(key string, defaultValue bool) bool

func (*TypeConverter) TryGetByte

func (t *TypeConverter) TryGetByte(key string, defaultValue byte) byte

func (*TypeConverter) TryGetComplex128

func (t *TypeConverter) TryGetComplex128(key string, defaultValue complex128) complex128

func (*TypeConverter) TryGetComplex64

func (t *TypeConverter) TryGetComplex64(key string, defaultValue complex64) complex64

func (*TypeConverter) TryGetFloat32

func (t *TypeConverter) TryGetFloat32(key string, defaultValue float32) float32

func (*TypeConverter) TryGetFloat64

func (t *TypeConverter) TryGetFloat64(key string, defaultValue float64) float64

func (*TypeConverter) TryGetInt

func (t *TypeConverter) TryGetInt(key string, defaultValue int) int

func (*TypeConverter) TryGetInt64

func (t *TypeConverter) TryGetInt64(key string, defaultValue int64) int64

func (*TypeConverter) TryGetString

func (t *TypeConverter) TryGetString(key string, defaultValue string) string

func (*TypeConverter) TryGetUint

func (t *TypeConverter) TryGetUint(key string, defaultValue uint) uint

func (*TypeConverter) TryGetUint64

func (t *TypeConverter) TryGetUint64(key string, defaultValue uint64) uint64

type Watcher

type Watcher interface {
	Watch(reloadToken ChangeToken) error
	IsWatching() bool
	Close() error
}

func NewFileWatcher

func NewFileWatcher(filePath string) (Watcher, error)

type YamlConfSource

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

func NewYamlConfSource

func NewYamlConfSource(yamlMessage []byte) *YamlConfSource

func (*YamlConfSource) Build

func (s *YamlConfSource) Build(builder ConfBuilder) (ConfProvider, error)

func (*YamlConfSource) Load

func (s *YamlConfSource) Load() (map[string]interface{}, error)

type YamlFileConfSource

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

func NewYamlFileConfSource

func NewYamlFileConfSource(path string) *YamlFileConfSource

func (*YamlFileConfSource) Build

func (s *YamlFileConfSource) Build(builder ConfBuilder) (ConfProvider, error)

func (*YamlFileConfSource) GetFileInfo

func (s *YamlFileConfSource) GetFileInfo() FileInfo

func (*YamlFileConfSource) GetFilePath

func (s *YamlFileConfSource) GetFilePath() string

func (*YamlFileConfSource) GetOnConfChangedCallback

func (s *YamlFileConfSource) GetOnConfChangedCallback() func(ConfChanges)

func (*YamlFileConfSource) IsEndureIfNotExist

func (s *YamlFileConfSource) IsEndureIfNotExist() bool

func (*YamlFileConfSource) IsFileExist

func (s *YamlFileConfSource) IsFileExist() bool

func (*YamlFileConfSource) Load

func (s *YamlFileConfSource) Load() (map[string]interface{}, error)

func (*YamlFileConfSource) SetEndureIfNotExist

func (s *YamlFileConfSource) SetEndureIfNotExist(endureIfNotExist bool) FileConfSource

func (*YamlFileConfSource) SetOnConfChangedCallback

func (s *YamlFileConfSource) SetOnConfChangedCallback(onConfChangedCallback func(ConfChanges)) FileConfSource

Directories

Path Synopsis
test
log
yml

Jump to

Keyboard shortcuts

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