Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses a raw field map into a config struct T using struct tags. Unknown keys are rejected. See ParsePartial for a variant that passes unknown keys through.
Supported struct tags:
- `config:"key_name"` — the YAML/env field name (required for the field to be parsed)
- `default:"123"` — default value for non-pointer int fields (bool defaults to false, int defaults to 0)
- `min:"0"` — minimum value for int fields (inclusive)
- `max:"500"` — maximum value for int fields (inclusive)
Pointer fields (*bool, *int) default to nil (unset).
func ParseBoolValue ¶
ParseBoolValue converts a raw YAML/env value to bool. Accepts bool and string ("true"/"false") types.
func ParseIntValue ¶
ParseIntValue converts a raw YAML/env value to int. Accepts int, int64, float64 (no decimals), and string types.
Types ¶
type BaseConfig ¶
type BaseConfig struct {
Enabled *bool `config:"enabled"`
IntervalSeconds *int `config:"interval_seconds" min:"0"`
}
BaseConfig holds universal fields that apply to every collector.
func (BaseConfig) IntervalOr ¶
IntervalOr returns the configured interval or def when unset or zero. A non-zero value less than def is an error — users can slow collection down but not speed it up beyond the default.
func (BaseConfig) IsEnabled ¶
func (b BaseConfig) IsEnabled() bool
IsEnabled returns true if the collector is not explicitly disabled.
type TypedEntry ¶
type TypedEntry[T any] struct { Base BaseConfig Extra T }
TypedEntry pairs a BaseConfig with a typed per-collector config.