Documentation
¶
Overview ¶
Package config stores katanomi configuration manager which watch configmap and work immediately if configmap changed
Index ¶
- Constants
- func ConfigFilter(ctx context.Context, manager *Manager, configKey string, ...) func(*restful.Request, *restful.Response, *restful.FilterChain)
- func ConfigFilterNotFoundWhenNotTrue(ctx context.Context, req *restful.Request, key string, value FeatureValue) (err error)
- func GetDurationConfig(ctx context.Context, key string, defaultDuration time.Duration) time.Duration
- func Name() string
- func WithKatanomiConfigManager(ctx context.Context, manager *Manager) context.Context
- type Config
- type ConfigKeyExpectedValueFunc
- type FeatureFlags
- type FeatureValue
- type HasFeatureChangedFunc
- type ListByFeatureFlagChanged
- type Manager
- type ManagerInterface
- type WatchFunc
- type Watcher
Constants ¶
const (
// PprofEnabledKey indicates the configuration key of the /debug/pprof debugging api/
PprofEnabledKey = "pprof.enabled"
)
Variables ¶
This section is empty.
Functions ¶
func ConfigFilter ¶
func ConfigFilter(ctx context.Context, manager *Manager, configKey string, expectedKeyValueFunc ConfigKeyExpectedValueFunc) func(*restful.Request, *restful.Response, *restful.FilterChain)
ConfigFilter adds a restful filter to manager to watch configmap and and custom validation according a specific key value pair.
func ConfigFilterNotFoundWhenNotTrue ¶
func ConfigFilterNotFoundWhenNotTrue(ctx context.Context, req *restful.Request, key string, value FeatureValue) (err error)
ConfigFilterNotFoundWhenNotTrue is a helper ConfigKeyExpectedValue implementation that checks if the value is a boolean true value, if not true will return a standard 404 not found error
Types ¶
type Config ¶
Config store katanomi configuration
type ConfigKeyExpectedValueFunc ¶
type ConfigKeyExpectedValueFunc func(ctx context.Context, req *restful.Request, key string, value FeatureValue) (err error)
ConfigKeyExpectedValueFunc is a helper function to check if configmap has expected value If the value is not as expected, an error is expected to be returned
type FeatureFlags ¶
FeatureFlags holds the features configurations
func (*FeatureFlags) FeatureValue ¶
func (f *FeatureFlags) FeatureValue(flag string) FeatureValue
FeatureValue returns the value of the implemented feature flag, or the default if not found.
type FeatureValue ¶
type FeatureValue string
FeatureValue definition of FeatureValue feature value
const ( // True represents the value "true" for the feature switch. True FeatureValue = "true" // False represents the value "false" for the feature switch. False FeatureValue = "false" // DefaultPprofEnabled stores the default value "false" for the "pprof.enabled" /debug/pprof debugging api. // If the corresponding key does not exist, the default value is returned. DefaultPprofEnabled FeatureValue = False )
func (FeatureValue) AsBool ¶
func (f FeatureValue) AsBool() (bool, error)
AsBool returns as a Bool, or false if the conversion fails.
func (FeatureValue) AsDuration ¶
func (f FeatureValue) AsDuration() (time.Duration, error)
AsBool returns as a Duration, or 0 if the conversion fails.
func (FeatureValue) AsInt ¶
func (f FeatureValue) AsInt() (int, error)
AsInt returned as an integer, or -1 if the conversion fails.
type HasFeatureChangedFunc ¶
type HasFeatureChangedFunc func(new *FeatureFlags, old *FeatureFlags) bool
HasFeatureChangedFunc check whether the function switch of interest has changed.
type ListByFeatureFlagChanged ¶
ListByFeatureFlagChanged when the function switch is changed, get the object function that triggers reconile.
type Manager ¶
type Manager struct {
Informer watcher.DefaultingWatcherWithOnChange
Logger *zap.SugaredLogger
*Config
// contains filtered or unexported fields
}
Manager will manage katanomi configuration and store in Config
func KatanomiConfigManager ¶
KatanomiConfigManager returns a Config Manager, returns nil if not found
func NewManager ¶
func NewManager(informer watcher.DefaultingWatcherWithOnChange, logger *zap.SugaredLogger, cmName string) *Manager
NewManager will instantiate a manager that watch configmap for core component configuration
func (*Manager) AddWatcher ¶
AddWatcher add a watcher to manager the watcher will be called when the configmap is changed
func (*Manager) GetFeatureFlag ¶
func (manager *Manager) GetFeatureFlag(flag string) FeatureValue
GetFeatureFlag get the function switch data, if the function switch is not set, return the default value of the switch.
func (*Manager) GetFeatureFlagByClient ¶
func (manager *Manager) GetFeatureFlagByClient(ctx context.Context, flag string) FeatureValue
GetFeatureFlagByClient get the config configuration by requesting configmap from the client. prioritize the use of GetFeatureFlag, and use the current function in scenarios that require high real-time data.
type ManagerInterface ¶
type ManagerInterface interface {
GetConfig() *Config
GetFeatureFlag(flag string) FeatureValue
}
type Watcher ¶
type Watcher interface {
Watch(config *Config)
}
Watcher describes the interface for config watcher
func NewConfigWatcher ¶
NewConfigWatcher constructs a new config watcher please note that the callback should be processed quickly and should not block