configurator

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterUnmarshaler

func RegisterUnmarshaler(name string, fn LoaderFn)

RegisterUnmarshaler registers an unmarshaler.

Types

type Config

type Config struct {
	// Type is the value type, yaml, json or toml.
	Type string `json:",default=yaml,options=[yaml,json,toml]"`
	// Log is the flag to control logging.
	Log bool `json:",default=true"`
}

Config is the configuration for Configurator.

type Configurator

type Configurator[T any] interface {
	// GetConfig returns the subscription value.
	GetConfig() (T, error)
	// AddListener adds a listener to the subscriber.
	AddListener(listener func())
}

Configurator is the interface for configuration center.

func MustNewConfigCenter

func MustNewConfigCenter[T any](c Config, subscriber subscriber.Subscriber) Configurator[T]

MustNewConfigCenter returns a Configurator, exits on errors.

func NewConfigCenter

func NewConfigCenter[T any](c Config, subscriber subscriber.Subscriber) (Configurator[T], error)

NewConfigCenter returns a Configurator.

type LoaderFn

type LoaderFn func([]byte, any) error

LoaderFn is the function type for loading configuration.

func Unmarshaler

func Unmarshaler(name string) (LoaderFn, bool)

Unmarshaler returns the unmarshaler by name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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