config

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package config handles config struct parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgType added in v0.6.0

type CfgType interface {
	fmt.Stringer
	SetString(string) error
}

CfgType represents an interface which any config field type must implement.

type ChangeNotification added in v0.11.0

type ChangeNotification struct {
	Name     string
	Type     string
	Previous string
	Current  string
}

ChangeNotification definition for a configuration change.

func (ChangeNotification) String added in v0.11.0

func (n ChangeNotification) String() string

type Config

type Config struct {
	Fields []*Field
}

Config manages configuration and handles updates on the values.

func New

func New(cfg interface{}, chNotify chan<- ChangeNotification) (*Config, error)

New creates a new monitor.

type Field

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

Field definition of a config value that can change.

func (*Field) Name

func (f *Field) Name() string

Name getter.

func (*Field) Set

func (f *Field) Set(value string, version uint64) error

Set the value of the field.

func (*Field) Sources

func (f *Field) Sources() map[Source]string

Sources getter.

func (*Field) String added in v0.4.0

func (f *Field) String() string

String returns string representation of field's value.

func (*Field) Type

func (f *Field) Type() string

Type getter.

type Source

type Source string

Source definition.

const (
	// SourceSeed defines a seed value.
	SourceSeed Source = "seed"
	// SourceEnv defines a value from environment variables.
	SourceEnv Source = "env"
	// SourceConsul defines a value from consul.
	SourceConsul Source = "consul"
	// SourceRedis defines a value from redis.
	SourceRedis Source = "redis"
	// SourceFlag defines a value from CLI flag.
	SourceFlag Source = "flag"
	// SourceFile defines a value from external file.
	SourceFile Source = "file"
)

Jump to

Keyboard shortcuts

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