Documentation ¶
Index ¶
- func SetOptions[T any](entity T, optSetters ...func(T) (T, error)) (T, error)
- type ConfigOption
- func BoolConfigOption[T any](name, description string, defaultVal bool, setter func(T, bool) (T, error)) *ConfigOption[T, bool]
- func DurationConfigOption[T any](name, description string, defaultVal time.Duration, ...) *ConfigOption[T, time.Duration]
- func IntConfigOption[T any](name, description string, defaultVal int, setter func(T, int) (T, error)) *ConfigOption[T, int]
- func StringConfigOption[T any](name, description string, defaultVal string, setter func(T, string) (T, error)) *ConfigOption[T, string]
- func StringSliceConfigOption[T any](name, description string, defaultVal []string, ...) *ConfigOption[T, []string]
- type Configurer
- type Entry
- type FactoryFunc
- type Option
- type Registry
- func (r Registry[T]) AllEntries() []Entry[T]
- func (r Registry[T]) Entry(name string) (Entry[T], bool)
- func (r Registry[T]) NewEntity(name string, optSetters ...func(T) (T, error)) (T, error)
- func (r Registry[T]) Options(name string) ([]Configurer, bool)
- func (r Registry[T]) Register(name string, factoryFunc FactoryFunc[T], opts ...Configurer) Entry[T]
- func (r Registry[T]) SetDefaultVals(entity T, opts []Configurer) (T, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetOptions ¶
Types ¶
type ConfigOption ¶
func BoolConfigOption ¶
func DurationConfigOption ¶
func IntConfigOption ¶
func StringConfigOption ¶
func StringSliceConfigOption ¶
func (*ConfigOption[T, TOption]) DefaultVal ¶
func (co *ConfigOption[T, TOption]) DefaultVal() TOption
func (*ConfigOption[T, TOption]) Description ¶
func (co *ConfigOption[T, TOption]) Description() string
func (*ConfigOption[T, TOption]) Name ¶
func (co *ConfigOption[T, TOption]) Name() string
func (*ConfigOption[T, TOption]) SetPrefix ¶
func (co *ConfigOption[T, TOption]) SetPrefix(prefix string)
func (*ConfigOption[T, TOption]) Setter ¶
func (co *ConfigOption[T, TOption]) Setter() func(T, TOption) (T, error)
type Configurer ¶
type Entry ¶
type Entry[T any] struct { Factory FactoryFunc[T] Name string Options []Configurer }
Entry contains information about each of the Entities in the Registry including the factory function, name, and configurable options
type FactoryFunc ¶
type FactoryFunc[T any] func() T
FactoryFunc is a function that will create an instantiation of an Entity
type Registry ¶
type Registry[T any] struct { // contains filtered or unexported fields }
Registry is a way for the library to expose details about available configuration options for a collection of Entities at run time. This is useful to do things such as expose attestor configuration options to Witness CLI. This lets the CLI create flags for all the available options at run time.
func (Registry[T]) AllEntries ¶
AllEntries returns every Entry in the Registry
func (Registry[T]) Entry ¶
Entry returns the Registry Entry for an Entity with the provided name. If an entity with the provided name cannot be found in the Registry, the boolean return value will be false.
func (Registry[T]) Options ¶
func (r Registry[T]) Options(name string) ([]Configurer, bool)
Options returns all of the available options an Entity with the provided name. If an Entity with the provided name cannot be found in the Registry the boolean return value will be false.
func (Registry[T]) Register ¶
func (r Registry[T]) Register(name string, factoryFunc FactoryFunc[T], opts ...Configurer) Entry[T]
Register adds an Entry to the Registry for an Entity
func (Registry[T]) SetDefaultVals ¶
func (r Registry[T]) SetDefaultVals(entity T, opts []Configurer) (T, error)
SetDefaultVals will take an Entity and call Setter for every option with that option's defaultVal.