cfgm

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cfgm implements a configuration module.

Index

Constants

View Source
const (
	DisabledValue = "<disabled>"
	DefaultValue  = "<default>"
)

Common sentinel values.

Variables

This section is empty.

Functions

func MustGet

func MustGet[T Config](ctx context.Context) T

MustGet extracts, panics if not found or T is wrong.

func NewInitializer

func NewInitializer[T Config](cfgLoader ConfigLoader[T]) injectz.Initializer

NewInitializer returns a injectz.Initializer that uses the given ConfigLoader.

func NewSingletonInjector

func NewSingletonInjector[T Config](cfg T) injectz.Injector

NewSingletonInjector injects.

Types

type Config

type Config interface {
	Config()
}

Config describes a set of configuration values.

type ConfigLoader

type ConfigLoader[T Config] func(ctx context.Context) (T, error)

ConfigLoader describes a function that can load a Config, for example from environment variables or JSON file.

func MustNewEnvConfigLoader

func MustNewEnvConfigLoader[T Config](options *EnvConfigLoaderOptions, enableValidation bool) ConfigLoader[T]

MustNewEnvConfigLoader returns a ConfigLoader that loads the config from environment variables. Under the hood it uses "github.com/caarlos0/env/v11". T must be a struct pointer.

type EnvConfigLoaderOptions

type EnvConfigLoaderOptions = env.Options

EnvConfigLoaderOptions describes the options for MustNewEnvConfigLoader.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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