config

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 18 Imported by: 6

README

flam-config

Go-linter Go-test

flam-config is a flam-in-go extension to provide configuration functionalities

Documentation

Index

Constants

View Source
const (
	ParserCreatorGroup         = "flam.config.parsers.creator"
	ParserDriverYaml           = "flam.config.parsers.driver.yaml"
	ParserDriverJson           = "flam.config.parsers.driver.json"
	SourceCreatorGroup         = "flam.config.sources.creator"
	SourceDriverEnv            = "flam.config.sources.driver.env"
	SourceDriverFile           = "flam.config.sources.driver.file"
	SourceDriverObservableFile = "flam.config.sources.driver.observable-file"
	SourceDriverDir            = "flam.config.sources.driver.dir"
	SourceDriverRest           = "flam.config.sources.driver.rest"
	SourceDriverObservableRest = "flam.config.sources.driver.observable-rest"

	PathDefaultFileParser = "flam.config.defaults.file.parser"
	PathDefaultFileDisk   = "flam.config.defaults.file.disk"
	PathDefaultRestParser = "flam.config.defaults.rest.parser"
	PathBoot              = "flam.config.boot"
	PathObserverFrequency = "flam.config.observer.frequency"
	PathParsers           = "flam.config.parsers"
	PathSources           = "flam.config.sources"
)

Variables

View Source
var (
	Defaults = flam.Bag{}

	DefaultFileParser = ""
	DefaultFileDisk   = ""
	DefaultRestParser = ""
)
View Source
var (
	ErrRestConfigNotFound    = errors.New("rest config data not found")
	ErrRestInvalidConfig     = errors.New("invalid rest config data")
	ErrRestTimestampNotFound = errors.New("rest config timestamp not found")
	ErrRestInvalidTimestamp  = errors.New("invalid rest config timestamp")
	ErrSourceNotFound        = errors.New("config source not found")
	ErrDuplicateSource       = errors.New("duplicate config source")
	ErrDuplicateObserver     = errors.New("duplicate config observer")
)

Functions

func Convert

func Convert(
	val any,
) any

func NewProvider

func NewProvider() flam.Provider

Types

type Facade

type Facade interface {
	Entries() []string
	Has(path string) bool
	Get(path string, def ...any) any
	Bool(path string, def ...bool) bool
	Int(path string, def ...int) int
	Int8(path string, def ...int8) int8
	Int16(path string, def ...int16) int16
	Int32(path string, def ...int32) int32
	Int64(path string, def ...int64) int64
	Uint(path string, def ...uint) uint
	Uint8(path string, def ...uint8) uint8
	Uint16(path string, def ...uint16) uint16
	Uint32(path string, def ...uint32) uint32
	Uint64(path string, def ...uint64) uint64
	Float32(path string, def ...float32) float32
	Float64(path string, def ...float64) float64
	String(path string, def ...string) string
	StringMap(path string, def ...map[string]any) map[string]any
	StringMapString(path string, def ...map[string]string) map[string]string
	Slice(path string, def ...[]any) []any
	StringSlice(path string, def ...[]string) []string
	Duration(path string, def ...time.Duration) time.Duration
	Bag(path string, def ...flam.Bag) flam.Bag
	Set(path string, value any) error
	Populate(target any, path ...string) error

	HasParser(id string) bool
	ListParsers() []string
	GetParser(id string) (Parser, error)
	AddParser(id string, source Parser) error

	HasSource(id string) bool
	ListSources() []string
	GetSource(id string) (Source, error)
	AddSource(id string, source Source) error
	SetSourcePriority(id string, priority int) error
	RemoveSource(id string) error
	RemoveAllSources() error
	ReloadSources() error

	HasObserver(id, path string) bool
	AddObserver(id, path string, callback Observer) error
	RemoveObserver(id string) error
}

type ObservableSource

type ObservableSource interface {
	Source

	Reload() (bool, error)
}

type Observer

type Observer func(old, new any)

type Parser

type Parser interface {
	io.Closer

	Parse(reader io.Reader) (flam.Bag, error)
}

type ParserCreator

type ParserCreator interface {
	Accept(config flam.Bag) bool
	Create(config flam.Bag) (Parser, error)
}

type RestRequester

type RestRequester interface {
	Do(req *http.Request) (*http.Response, error)
}

type RestRequesterGenerator

type RestRequesterGenerator interface {
	Create() (RestRequester, error)
}

type Source

type Source interface {
	io.Closer

	GetPriority() int
	SetPriority(priority int)
	Get(path string, def ...any) any
}

type SourceCreator

type SourceCreator interface {
	Accept(config flam.Bag) bool
	Create(config flam.Bag) (Source, error)
}

Jump to

Keyboard shortcuts

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