updatable_configs

package
v0.28.15-access-admin-... Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 added in v0.28.13

func IsValidationError(err error) bool

func NewSealingConfigs

func NewSealingConfigs(
	requiredApprovalsForSealConstruction uint,
	requiredApprovalsForSealVerification uint,
	chunkAlpha uint,
	emergencySealingActive bool,
) (module.SealingConfigsSetter, error)

Types

type Field added in v0.28.13

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 added in v0.28.13

type GetAnyConfigFunc func() any

type GetBoolConfigFunc added in v0.28.13

type GetBoolConfigFunc func() bool

type GetDurationConfigFunc added in v0.28.13

type GetDurationConfigFunc func() time.Duration

type GetUintConfigFunc added in v0.28.13

type GetUintConfigFunc func() uint

type Manager added in v0.28.13

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 added in v0.28.13

func NewManager() *Manager

func (*Manager) AllFields added in v0.28.13

func (m *Manager) AllFields() []Field

AllFields returns all currently registered fields.

func (*Manager) GetField added in v0.28.13

func (m *Manager) GetField(name string) (Field, bool)

GetField returns the updatable config field with the given name, if one exists.

func (*Manager) RegisterBoolConfig added in v0.28.13

func (m *Manager) RegisterBoolConfig(name string, get GetBoolConfigFunc, set SetBoolConfigFunc) error

func (*Manager) RegisterDurationConfig added in v0.28.13

func (m *Manager) RegisterDurationConfig(name string, get GetDurationConfigFunc, set SetDurationConfigFunc) error

func (*Manager) RegisterUintConfig added in v0.28.13

func (m *Manager) RegisterUintConfig(name string, get GetUintConfigFunc, set SetUintConfigFunc) error

type Registrar added in v0.28.13

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
}

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 added in v0.28.13

type SetAnyConfigFunc func(any) error

type SetBoolConfigFunc added in v0.28.13

type SetBoolConfigFunc func(bool) error

type SetDurationConfigFunc added in v0.28.13

type SetDurationConfigFunc func(time.Duration) error

type SetUintConfigFunc added in v0.28.13

type SetUintConfigFunc func(uint) error

type ValidationError added in v0.28.13

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 added in v0.28.13

func NewValidationErrorf(msg string, args ...any) ValidationError

func (ValidationError) Error added in v0.28.13

func (err ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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