config

package
v2.0.0-...-c87de9c Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config is an interface for dynamic configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(old, new value.Value)

type Config

type Config interface {
	Path() string
	Validate() error
}

type Configurator

type Configurator interface {
	Load() error                         // Load config sources
	Scan(val interface{}) error          // Scan to val
	Value(key string) value.Value        // Value get values through key
	Watch(key string, cb Callback) error // Watch key change
	Close() error                        // Close stop the config loader/watcher
}

Configurator is an interface abstraction for dynamic configuration

func NewConfig

func NewConfig(opts ...Option) Configurator

NewConfig returns new config

type Option

type Option func(o *Options)

func WithDebug

func WithDebug(debug bool) Option

WithDebug print debug log

func WithInterval

func WithInterval(interval time.Duration) Option

WithInterval sets watch interval

func WithReader

func WithReader(r reader.Reader) Option

WithReader sets the config reader

func WithSource

func WithSource(s ...source.Source) Option

WithSource appends a source to list of sources, the latter has higher priority.

type Options

type Options struct {
	Debug    io.Writer
	Interval time.Duration
	Source   []source.Source
	Reader   reader.Reader
	Context  context.Context
}

Directories

Path Synopsis
Package reader parses change sets and provides config values
Package reader parses change sets and provides config values
Package source is the interface for sources
Package source is the interface for sources
env
file
Package file is a file source.
Package file is a file source.

Jump to

Keyboard shortcuts

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