config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigType     = "yaml"
	DefaultConfigDir      = "./appconfig"
	DefaultConfigFileName = "default"
	WorkDirEnv            = "WORKDIR"
	EnvPrefix             = "env|"
	FilePrefix            = "file|"
)

Default options for configuration loading.

Variables

This section is empty.

Functions

func SubstituteConfigValues

func SubstituteConfigValues(v reflect.Value)

SubstituteConfigValues recursively walks through the config struct and replaces string values of the form 'env|VAR' or 'file|/path' with the corresponding value.

Types

type App

type App struct {
	Name        string `yaml:"name"`
	Version     string `yaml:"version"`
	Environment string `yaml:"environment"`
}

App represents the application configuration

type AppConfig

type AppConfig struct {
	App        App                       `yaml:"app"`
	LDAP       ldap.LDAP                 `yaml:"ldap"`
	Cache      cache.Config              `yaml:"cache"`
	Backends   []Backend                 `yaml:"backends"`
	Pattern    map[string][]PatternEntry `yaml:"pattern"`
	HttpClient struct {
		ConnectionPoolConfig    httpclient.ConnectionPoolConfig    `yaml:"connectionPoolConfig"`
		HystrixResiliencyConfig httpclient.HystrixResiliencyConfig `yaml:"hystrixResiliencyConfig"`
	} `yaml:"httpClient"`
	BackendMap map[string]map[string]Backend `yaml:"-"`
}

Config represents the top-level configuration structure

func GetConfig

func GetConfig() (*AppConfig, error)

func LoadConfig

func LoadConfig(env string) (*AppConfig, error)

type Backend

type Backend struct {
	Name       string                 `yaml:"name"`
	Type       string                 `yaml:"type"`
	Enabled    bool                   `yaml:"enabled"`
	Connection map[string]interface{} `yaml:"connection"`
}

Backend represents a backend service configuration

func (*Backend) GetStringConnection

func (b *Backend) GetStringConnection(name string, defaultValue string) string

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is a wrapper over a underlying config loader implementation.

func NewConfig

func NewConfig(opts Options) *Config

NewConfig returns new config struct.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns new config struct with default options.

func (*Config) Load

func (c *Config) Load(env string, config interface{}) error

Load reads environment specific configurations and along with the defaults unmarshalls into config.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options is config options.

func NewDefaultOptions

func NewDefaultOptions() Options

func NewOptions

func NewOptions(configType string, configPath string, defaultConfigFileName string) Options

NewOptions returns new Options struct.

type PatternEntry

type PatternEntry struct {
	Input  string `yaml:"input"`
	Output string `yaml:"output"`
}

PatternEntry represents the input and output pattern of group names

Jump to

Keyboard shortcuts

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