config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config[T any] interface {
	Scan(v *T) error
	Watch(key string, o Observer[T]) error
	Close() error
}

Config is a config interface.

func New

func New[T any](opts ...Option) Config[T]

type Decoder

type Decoder func(*KeyValue, map[string]any) error

Decoder is config decoder.

type KeyValue

type KeyValue struct {
	Key    string
	Value  []byte
	Format string
}

KeyValue is config key value.

type Merge

type Merge func(dst, src any) error

Merge is config merge func.

type Observer

type Observer[T any] func(string, *T)

Observer is config observer.

type Option

type Option func(*options)

Option is config option.

func WithDecoder

func WithDecoder(d Decoder) Option

WithDecoder with config decoder. DefaultDecoder behavior: If KeyValue.Format is non-empty, then KeyValue.Value will be deserialized into map[string]any and stored in the config cache(map[string]any) if KeyValue.Format is empty,{KeyValue.Key : KeyValue.Value} will be stored in config cache(map[string]any)

func WithMergeFunc

func WithMergeFunc(m Merge) Option

WithMergeFunc with config merge func.

func WithResolver

func WithResolver(r Resolver) Option

WithResolver with config resolver.

func WithSource

func WithSource(s ...Source) Option

WithSource with config source.

type Resolver

type Resolver func(map[string]any) error

Resolver resolve placeholder in config.

type Source

type Source interface {
	Load() ([]*KeyValue, error)
	Watch() (Watcher, error)
}

Source is config source.

type Unmarshal

type Unmarshal func(data []byte, v any) error

type Watcher

type Watcher interface {
	Next() ([]*KeyValue, error)
	Stop() error
}

Watcher watches a source for changes.

Directories

Path Synopsis
provider

Jump to

Keyboard shortcuts

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