Documentation
¶
Index ¶
- Constants
- Variables
- type CollectionRetrievalStrategy
- type ConfigManager
- type DynamicType
- type DynamicValue
- func (dv *DynamicValue[T]) Get() T
- func (dv *DynamicValue[T]) MarshalJSON() ([]byte, error)
- func (dv *DynamicValue[T]) MarshalYAML() (any, error)
- func (dv *DynamicValue[T]) Reset()
- func (dv *DynamicValue[T]) SetValue(val T)
- func (dv *DynamicValue[T]) String() string
- func (dv *DynamicValue[T]) UnmarshalJSON(data []byte) error
- func (dv *DynamicValue[T]) UnmarshalYAML(node *yaml.Node) error
- type FeatureFlag
- type LDIntegration
- type Parser
- type SupportedTypes
- type Updater
Constants ¶
const ( WeaviateLDApiKey = "WEAVIATE_LD_API_KEY" WeaviateLDClusterKey = "WEAVIATE_LD_CLUSTER_KEY" WeaviateLDOrgKey = "WEAVIATE_LD_ORG_KEY" LDContextOrgKey = "org" LDContextClusterKey = "cluster" LDContextNodeKey = "node" )
Variables ¶
var ( ErrEmptyConfig = errors.New("empty runtime config") ErrFailedToOpenConfig = errors.New("failed to open runtime config") ErrFailedToReadConfig = errors.New("failed to read runtime config ") ErrFailedToParseConfig = errors.New("failed to parse runtime config ") ErrUnregisteredConfigFound = errors.New("unregistered config found") )
Functions ¶
This section is empty.
Types ¶
type CollectionRetrievalStrategy ¶
type CollectionRetrievalStrategy string
const ( LeaderOnly CollectionRetrievalStrategy = "LeaderOnly" LocalOnly CollectionRetrievalStrategy = "LocalOnly" LeaderOnMismatch CollectionRetrievalStrategy = "LeaderOnMismatch" CollectionRetrievalStrategyEnvVariable = "COLLECTION_RETRIEVAL_STRATEGY" CollectionRetrievalStrategyLDKey = "collection-retrieval-strategy" )
type ConfigManager ¶ added in v1.30.0
type ConfigManager[T any] struct { // contains filtered or unexported fields }
ConfigManager takes care of periodically loading the config from given filepath for every interval period.
func NewConfigManager ¶ added in v1.30.0
func NewConfigManager[T any]( filepath string, parser Parser[T], updater Updater[T], registered *T, interval time.Duration, log logrus.FieldLogger, r prometheus.Registerer, ) (*ConfigManager[T], error)
func (*ConfigManager[T]) RegisterHooks ¶ added in v1.31.21
func (cm *ConfigManager[T]) RegisterHooks(hooks map[string]func() error)
RegisterHooks registers any hooks that should be enabled prior runtime config start
func (*ConfigManager[T]) Run ¶ added in v1.30.0
func (cm *ConfigManager[T]) Run(ctx context.Context) error
Run is a blocking call that starts the configmanager actor. Consumer probably want to call it in different goroutine. It also respects the passed in `ctx`. Meaning, cancelling the passed `ctx` stops the actor.
type DynamicType ¶ added in v1.30.2
DynamicType represents different types that is supported in runtime configs
type DynamicValue ¶ added in v1.30.2
type DynamicValue[T DynamicType] struct { // contains filtered or unexported fields }
DynamicValue represents any runtime config value. It's zero value is fully usable. If you want zero value with different `default`, use `NewDynamicValue` constructor.
func NewDynamicValue ¶ added in v1.30.2
func NewDynamicValue[T DynamicType](val T) *DynamicValue[T]
NewDynamicValue returns an instance of DynamicValue as passed in type with passed in value as default.
func (*DynamicValue[T]) Get ¶ added in v1.30.2
func (dv *DynamicValue[T]) Get() T
Get returns a current value for the given config. It can either be dynamic value or default value (if unable to get dynamic value) Consumer of the dynamic config value should care only about this `Get()` api.
func (*DynamicValue[T]) MarshalJSON ¶ added in v1.30.10
func (dv *DynamicValue[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements `json` custom encoding for `DynamicValue` type.
func (*DynamicValue[T]) MarshalYAML ¶ added in v1.30.10
func (dv *DynamicValue[T]) MarshalYAML() (any, error)
MarshalYAML implements `yaml.v3` custom encoding for `DynamicValue` type.
func (*DynamicValue[T]) Reset ¶ added in v1.30.2
func (dv *DynamicValue[T]) Reset()
Reset removes the old dynamic value.
func (*DynamicValue[T]) SetValue ¶ added in v1.30.2
func (dv *DynamicValue[T]) SetValue(val T)
Set is used by the config manager to update the dynamic value.
func (*DynamicValue[T]) String ¶ added in v1.30.10
func (dv *DynamicValue[T]) String() string
String implements Stringer interface for `%v` formatting for any dynamic value types.
func (*DynamicValue[T]) UnmarshalJSON ¶ added in v1.30.10
func (dv *DynamicValue[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements `json` custom decoding for `DynamicValue` type.
func (*DynamicValue[T]) UnmarshalYAML ¶ added in v1.30.2
func (dv *DynamicValue[T]) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements `yaml.v3` custom decoding for `DynamicValue` type.
type FeatureFlag ¶
type FeatureFlag[T SupportedTypes] struct { // contains filtered or unexported fields }
FeatureFlag is a generic structure that supports reading a value that can be changed by external factors at runtime (for example LD integration). It is meant to be used for configuration options that can be updated at runtime.
func NewFeatureFlag ¶
func NewFeatureFlag[T SupportedTypes](key string, defaultValue T, ldInteg *LDIntegration, envDefault string, logger logrus.FieldLogger) *FeatureFlag[T]
NewFeatureFlag returns a new feature flag of type T configured with key as the remote LD flag key (if LD integration is available) and defaultValue used as the default value of the flag.
func (*FeatureFlag[T]) Close ¶
func (f *FeatureFlag[T]) Close()
Close ensure that all internal ressources are freed
func (*FeatureFlag[T]) Get ¶
func (f *FeatureFlag[T]) Get() T
Get reads the current value of the feature flags and returns it.
func (*FeatureFlag[T]) WithOnChangeCallback ¶
func (f *FeatureFlag[T]) WithOnChangeCallback(onChange func(T, T)) *FeatureFlag[T]
WithOnChangeCallback registers onChange to be called everytime the value of the feature flag is changed at runtime These callbacks are blocking in the loop to update the feature flag, therefore the callback *must not* block.
type LDIntegration ¶
type LDIntegration struct {
// contains filtered or unexported fields
}
func ConfigureLDIntegration ¶
func ConfigureLDIntegration() (*LDIntegration, error)
ConfigureLDIntegration will configure the necessary global variables to have `FeatureFlag` struct be able to use LD flags
type Parser ¶ added in v1.30.0
Parser takes care of unmarshaling a config struct from given raw bytes(e.g: YAML, JSON, etc).
type SupportedTypes ¶
SupportedTypes is the generic type grouping that FeatureFlag can handle.