settings

package
v0.0.0-...-47294c1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package settings defines the interface for the component that manage settings that can be changed at runtime

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
	// RuntimeSettings returns the configurable settings
	RuntimeSettings() map[string]RuntimeSetting
	// GetRuntimeSetting returns the value of a runtime configurable setting
	GetRuntimeSetting(setting string) (interface{}, error)
	// SetRuntimeSetting changes the value of a runtime configurable setting
	SetRuntimeSetting(setting string, value interface{}, source model.Source) error

	// GetFullConfig returns the full config
	GetFullConfig(namespaces ...string) http.HandlerFunc
	// GetFullConfigBySource returns the full config by sources (config, default, env vars ...)
	GetFullConfigBySource() http.HandlerFunc
	// GetValue allows to retrieve the runtime setting
	GetValue(w http.ResponseWriter, r *http.Request)
	// SetValue allows to modify the runtime setting
	SetValue(w http.ResponseWriter, r *http.Request)
	// ListConfigurable returns the list of configurable setting at runtime
	ListConfigurable(w http.ResponseWriter, r *http.Request)
}

Component is the component type.

type Params

type Params struct {
	// Settings define the runtime settings the component would understand
	Settings map[string]RuntimeSetting
	// The config object in which the settings would apply operations
	Config config.Component
	// Optional namespace restriction that GetFullConfig would return settings for
	Namespaces []string
}

Params that the settings component need

type RuntimeSetting

type RuntimeSetting interface {
	Get(config config.Component) (interface{}, error)
	Set(config config.Component, v interface{}, source model.Source) error
	Description() string
	Hidden() bool
}

RuntimeSetting represents a setting that can be changed and read at runtime.

type RuntimeSettingProvider

type RuntimeSettingProvider struct {
	fx.Out

	Setting RuntimeSetting `group:"runtime_setting"`
}

RuntimeSettingProvider stores the Provider instance

func NewRuntimeSettingProvider

func NewRuntimeSettingProvider(runtimesetting RuntimeSetting) RuntimeSettingProvider

NewRuntimeSettingProvider returns a RuntimeSettingProvider

type RuntimeSettingResponse

type RuntimeSettingResponse struct {
	Description string
	Hidden      bool
}

RuntimeSettingResponse is used to communicate settings config

type SettingNotFoundError

type SettingNotFoundError struct {
	Name string
}

SettingNotFoundError is used to warn about non existing/not registered runtime setting

func (*SettingNotFoundError) Error

func (e *SettingNotFoundError) Error() string

Directories

Path Synopsis
Package settingsimpl implements the interface for the settings component
Package settingsimpl implements the interface for the settings component

Jump to

Keyboard shortcuts

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