Documentation
¶
Overview ¶
Package configsrc resolves a store's configuration: from a copy of the one given to the store's WithConfig option, or else by binding the store's defaults from a gas.ConfigProvider.
Usage ¶
A store keeps a Source of its Config, which WithConfig sets, and resolves a fresh configuration on each Init:
var src configsrc.Source[Config] src.Set(cfg) // from WithConfig, or never resolved, err := src.Resolve(cfgProvider, DefaultConfig, rules)
Resolving ¶
Source.Resolve never returns, and never changes, the struct given to Set: it returns a copy. With a configuration given to Set, the copy is checked against its `validate` tags; a nil one is an error wrapping queue.ErrNilConfig. Without one, the defaults are bound from the Binder, which checks the tags itself; a nil Binder is an error wrapping queue.ErrNoConfigProvider. Then the store's rules run on the result.
Errors ¶
A failed tag check, bind or rule wraps queue.ErrInvalidConfig, and, for the first two, the validator's or the binder's error, so that errors.As reaches validator.ValidationErrors. The errors, before the store's prefix:
config is nil no config provider invalid config: validate config: <the validator's error> invalid config: <the binder's error> invalid config: <the rule's error>
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binder ¶
type Binder interface {
// Bind fills the struct dest points to, then validates it.
Bind(dest any) error
}
Binder fills a struct from configuration and validates it. gas.ConfigProvider implements it.
type Source ¶
type Source[T any] struct { // contains filtered or unexported fields }
Source records where a store takes its configuration from, as described in the package documentation. The zero Source binds from the Binder.