cfg

package
v0.40.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B = 1

	// KB ,MB ,GB ,TB ,PB are Decimal
	KB = 1000 * B
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB

	// KiB ,MiB ,GiB ,TiB ,PiB are Binary
	KiB = 1024 * B
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
)

Variables

View Source
var DataUnitAliases = map[string]int{
	"kb": KB, "kib": KiB,
	"mb": MB, "mib": MiB,
	"gb": GB, "gib": GiB,
	"tb": TB, "tib": TiB,
	"pb": PB, "pib": PiB,
	"b": B,
}

DataUnitAliases is map to add alias. Alias must not contain space Only lowercase letters should be used in the map, but aliases are case-insensitive

Functions

func CompileRegex

func CompileRegex(s string) (*regexp.Regexp, error)

func DecodeConfig added in v0.18.0

func DecodeConfig(config any, configJson []byte) error

func GetKafkaClientOptions added in v0.29.0

func GetKafkaClientOptions(c KafkaClientConfig, l *zap.Logger) []kgo.Opt

func ListToMap

func ListToMap(a []string) map[string]bool

func Parse

func Parse(ptr any, values map[string]int) error

Parse holy shit! who write this function?

func ParseChild

func ParseChild(parent reflect.Value, v reflect.Value, values map[string]int) error

it isn't just a recursion it also captures values with the same name from parent i.e. take this config:

{
	"T": 10,
	"Child": { // has `child:true` in a tag
		"T": null
	}
}

this function will set `config.Child.T = config.T` see file.d/cfg/config_test.go:TestHierarchy for an example

func ParseField

func ParseField(v reflect.Value, vField reflect.Value, tField *reflect.StructField, values map[string]int) error

func ParseFieldSelector

func ParseFieldSelector(selector string) []string

func ParseSlice

func ParseSlice(v reflect.Value, values map[string]int) error

ParseSlice recursively parses elements of an slice calls Parse, not ParseChild (!)

func SetDefaultValues added in v0.18.0

func SetDefaultValues(data interface{}) error

func VerifyGroupNumbers added in v0.18.0

func VerifyGroupNumbers(groups []int, totalGroups int, logger *zap.Logger) []int

Types

type Base8

type Base8 string

type Config

type Config struct {
	Vault     VaultConfig
	Pipelines map[string]*PipelineConfig
}

func NewConfig

func NewConfig() *Config

func NewConfigFromFile

func NewConfigFromFile(path string) *Config

type Duration

type Duration string

type Expression

type Expression string

func (*Expression) UnmarshalJSON added in v0.8.9

func (e *Expression) UnmarshalJSON(raw []byte) error

type FieldSelector

type FieldSelector string

type KafkaClientConfig added in v0.29.0

type KafkaClientConfig interface {
	GetBrokers() []string
	GetClientID() string

	IsSaslEnabled() bool
	GetSaslConfig() KafkaClientSaslConfig

	IsSslEnabled() bool
	GetSslConfig() KafkaClientSslConfig
}

type KafkaClientSaslConfig added in v0.29.0

type KafkaClientSaslConfig struct {
	SaslMechanism string
	SaslUsername  string
	SaslPassword  string
}

type KafkaClientSslConfig added in v0.29.0

type KafkaClientSslConfig struct {
	CACert        string
	ClientCert    string
	ClientKey     string
	SslSkipVerify bool
}

type ListMap

type ListMap string

type MetaTemplates added in v0.26.0

type MetaTemplates map[string]string

type PipelineConfig

type PipelineConfig struct {
	Raw *simplejson.Json
}

type Regexp

type Regexp string

type VaultConfig

type VaultConfig struct {
	Token     string
	Address   string
	ShouldUse bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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