Documentation ¶
Index ¶
- Variables
- func IsValidationError(err error) bool
- func NewSealingConfigs(requiredApprovalsForSealConstruction uint, ...) (module.SealingConfigsSetter, error)
- type Field
- type GetAnyConfigFunc
- type GetBoolConfigFunc
- type GetDurationConfigFunc
- type GetIdentifierListConfigFunc
- type GetUintConfigFunc
- type Manager
- func (m *Manager) AllFields() []Field
- func (m *Manager) GetField(name string) (Field, bool)
- func (m *Manager) RegisterBoolConfig(name string, get GetBoolConfigFunc, set SetBoolConfigFunc) error
- func (m *Manager) RegisterDurationConfig(name string, get GetDurationConfigFunc, set SetDurationConfigFunc) error
- func (m *Manager) RegisterIdentifierListConfig(name string, get GetIdentifierListConfigFunc, set SetIdentifierListConfigFunc) error
- func (m *Manager) RegisterUintConfig(name string, get GetUintConfigFunc, set SetUintConfigFunc) error
- type Registrar
- type SetAnyConfigFunc
- type SetBoolConfigFunc
- type SetDurationConfigFunc
- type SetIdentifierListConfigFunc
- type SetUintConfigFunc
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRegistered = fmt.Errorf("config name already registered")
ErrAlreadyRegistered is returned when a config field is registered with a name conflicting with an already registered config field.
Functions ¶
func IsValidationError ¶
func NewSealingConfigs ¶
Types ¶
type Field ¶
type Field struct { // Name is the name of the config field, must be globally unique. Name string // TypeName is a human-readable string defining the expected type of inputs. TypeName string // Set is the setter function for the config field. It enforces validation rules // and applies the new config value. // Returns ValidationError if the new config value is invalid. Set SetAnyConfigFunc // Get is the getter function for the config field. It returns the current value // for the config field. Get GetAnyConfigFunc }
Field represents one dynamically configurable config field.
type GetAnyConfigFunc ¶
type GetAnyConfigFunc func() any
type GetBoolConfigFunc ¶
type GetBoolConfigFunc func() bool
type GetDurationConfigFunc ¶
type GetIdentifierListConfigFunc ¶
type GetIdentifierListConfigFunc func() flow.IdentifierList
type GetUintConfigFunc ¶
type GetUintConfigFunc func() uint
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages setter and getter for updatable configs, across all components. Components register updatable config fields with the manager at startup, then the Manager exposes the ability to dynamically update these configs while the node is running, for example, via admin commands.
The Manager maintains a list of type-agnostic updatable config fields. The typed registration function (Register*Config) is responsible for type conversion. The registration functions must convert input types (as parsed from JSON) to the Go type expected by the config field setter. They must also convert Go types from config field getters to displayable types (see structpb.NewValue for details).
func NewManager ¶
func NewManager() *Manager
func (*Manager) GetField ¶
GetField returns the updatable config field with the given name, if one exists.
func (*Manager) RegisterBoolConfig ¶
func (m *Manager) RegisterBoolConfig(name string, get GetBoolConfigFunc, set SetBoolConfigFunc) error
RegisterBoolConfig registers a new bool config. Setter inputs must be bool-typed values. Returns ErrAlreadyRegistered if a config is already registered with name.
func (*Manager) RegisterDurationConfig ¶
func (m *Manager) RegisterDurationConfig(name string, get GetDurationConfigFunc, set SetDurationConfigFunc) error
RegisterDurationConfig registers a new duration config. Setter inputs must be duration-parseable string-typed values. Returns ErrAlreadyRegistered if a config is already registered with name.
func (*Manager) RegisterIdentifierListConfig ¶
func (m *Manager) RegisterIdentifierListConfig(name string, get GetIdentifierListConfigFunc, set SetIdentifierListConfigFunc) error
RegisterIdentifierListConfig registers a new []Identifier config Setter inputs must be []any-typed values, with string elements parseable as Identifier. Returns ErrAlreadyRegistered if a config is already registered with name.
func (*Manager) RegisterUintConfig ¶
func (m *Manager) RegisterUintConfig(name string, get GetUintConfigFunc, set SetUintConfigFunc) error
RegisterUintConfig registers a new uint config. Setter inputs must be float64-typed values and will be truncated if not integral. Returns ErrAlreadyRegistered if a config is already registered with name.
type Registrar ¶
type Registrar interface { // RegisterBoolConfig registers a new bool config. // Returns ErrAlreadyRegistered if a config is already registered with name. RegisterBoolConfig(name string, get GetBoolConfigFunc, set SetBoolConfigFunc) error // RegisterUintConfig registers a new uint config. // Returns ErrAlreadyRegistered if a config is already registered with name. RegisterUintConfig(name string, get GetUintConfigFunc, set SetUintConfigFunc) error // RegisterDurationConfig registers a new duration config. // Returns ErrAlreadyRegistered if a config is already registered with name. RegisterDurationConfig(name string, get GetDurationConfigFunc, set SetDurationConfigFunc) error // RegisterIdentifierListConfig registers a new []Identifier config // Returns ErrAlreadyRegistered if a config is already registered with name. RegisterIdentifierListConfig(name string, get GetIdentifierListConfigFunc, set SetIdentifierListConfigFunc) error }
Registrar provides an interface for registering config fields which can be dynamically updated while the node is running. Configs must have globally unique names. Setter functions are responsible for enforcing component-specific validation rules, and returning a ValidationError if the new config value is invalid.
type SetAnyConfigFunc ¶
type SetBoolConfigFunc ¶
type SetDurationConfigFunc ¶
type SetIdentifierListConfigFunc ¶
type SetIdentifierListConfigFunc func(flow.IdentifierList) error
type SetUintConfigFunc ¶
type ValidationError ¶
type ValidationError struct {
Err error
}
ValidationError is returned by a config setter function (Set*ConfigFunc) when the provided config field is invalid, and was not applied.
func NewValidationErrorf ¶
func NewValidationErrorf(msg string, args ...any) ValidationError
func (ValidationError) Error ¶
func (err ValidationError) Error() string