feeders

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package feeders provides configuration feeders for reading data from various sources including environment variables, JSON, YAML, TOML files, and .env files.

Index

Constants

This section is empty.

Variables

View Source
var ErrEnvEmptyPrefixAndSuffix = errors.New("env: prefix or suffix cannot be empty")

ErrEnvEmptyPrefixAndSuffix indicates that both prefix and suffix cannot be empty

View Source
var ErrEnvInvalidStructure = errors.New("env: invalid structure")

ErrEnvInvalidStructure indicates that the provided structure is not valid for environment variable processing

Functions

This section is empty.

Types

type AffixedEnvFeeder

type AffixedEnvFeeder struct {
	Prefix string
	Suffix string
}

AffixedEnvFeeder is a feeder that reads environment variables with a prefix and/or suffix

func NewAffixedEnvFeeder

func NewAffixedEnvFeeder(prefix, suffix string) AffixedEnvFeeder

NewAffixedEnvFeeder creates a new AffixedEnvFeeder with the specified prefix and suffix

func (AffixedEnvFeeder) Feed

func (f AffixedEnvFeeder) Feed(structure interface{}) error

Feed reads environment variables and populates the provided structure

type DotEnvFeeder

type DotEnvFeeder = feeder.DotEnv

DotEnvFeeder is a feeder that reads .env files

func NewDotEnvFeeder

func NewDotEnvFeeder(filePath string) DotEnvFeeder

NewDotEnvFeeder creates a new DotEnvFeeder that reads from the specified .env file

type EnvFeeder

type EnvFeeder = feeder.Env

EnvFeeder is a feeder that reads environment variables

func NewEnvFeeder

func NewEnvFeeder() EnvFeeder

NewEnvFeeder creates a new EnvFeeder that reads from environment variables

type Feeder added in v1.2.6

type Feeder interface {
	Feed(target interface{}) error
}

Feeder interface for common operations

type JSONFeeder added in v1.2.6

type JSONFeeder struct {
	feeder.Json
}

JSONFeeder is a feeder that reads JSON files

func NewJSONFeeder added in v1.2.6

func NewJSONFeeder(filePath string) JSONFeeder

NewJSONFeeder creates a new JSONFeeder that reads from the specified JSON file

func (JSONFeeder) FeedKey added in v1.2.6

func (j JSONFeeder) FeedKey(key string, target interface{}) error

FeedKey reads a JSON file and extracts a specific key

type TenantAffixedEnvFeeder added in v1.1.0

type TenantAffixedEnvFeeder struct {
	*AffixedEnvFeeder
	SetPrefixFunc func(string)
	SetSuffixFunc func(string)
}

TenantAffixedEnvFeeder is a feeder that reads environment variables with tenant-specific prefixes and suffixes

func NewTenantAffixedEnvFeeder added in v1.1.0

func NewTenantAffixedEnvFeeder(prefix, suffix func(string) string) TenantAffixedEnvFeeder

NewTenantAffixedEnvFeeder creates a new TenantAffixedEnvFeeder with the given prefix and suffix functions The prefix and suffix functions are used to modify the prefix and suffix of the environment variables before they are used to set the struct fields The prefix and suffix functions should take a string and return a string The prefix function is used to modify the prefix of the environment variables The suffix function is used to modify the suffix of the environment variables

type TomlFeeder

type TomlFeeder struct {
	feeder.Toml
}

TomlFeeder is a feeder that reads TOML files

func NewTomlFeeder

func NewTomlFeeder(filePath string) TomlFeeder

NewTomlFeeder creates a new TomlFeeder that reads from the specified TOML file

func (TomlFeeder) FeedKey

func (t TomlFeeder) FeedKey(key string, target interface{}) error

FeedKey reads a TOML file and extracts a specific key

type YamlFeeder

type YamlFeeder struct {
	feeder.Yaml
}

YamlFeeder is a feeder that reads YAML files

func NewYamlFeeder

func NewYamlFeeder(filePath string) YamlFeeder

NewYamlFeeder creates a new YamlFeeder that reads from the specified YAML file

func (YamlFeeder) FeedKey

func (y YamlFeeder) FeedKey(key string, target interface{}) error

FeedKey reads a YAML file and extracts a specific key

Jump to

Keyboard shortcuts

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