runtime

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeaviateLDApiKey     = "WEAVIATE_LD_API_KEY"
	WeaviateLDClusterKey = "WEAVIATE_LD_CLUSTER_KEY"
	WeaviateLDOrgKey     = "WEAVIATE_LD_ORG_KEY"

	LDContextOrgKey     = "org"
	LDContextClusterKey = "cluster"
	LDContextNodeKey    = "node"
)

Variables

View Source
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 ")
)

Functions

func GetOverrides added in v1.30.0

func GetOverrides[T any](val T, f func() *T) T

GetOverrides takes a config value and func to get it's runtime value. It returns a value from func if available otherwise the passed in `val` if failing to get value from the func().

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],
	interval time.Duration,
	log logrus.FieldLogger,
	r prometheus.Registerer,
) (*ConfigManager[T], error)

func (*ConfigManager[T]) Config added in v1.30.0

func (cm *ConfigManager[T]) Config() (*T, error)

Config returns the current valid config if available. Once the config manager is started without any error, consumer should be able to get **valid** config via this api.

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 groutine. It also respects the passed in `ctx`. Meaning, cancelling the passed `ctx` stops the actor.

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

type Parser[T any] func([]byte) (*T, error)

Parser takes care of unmarshaling a config struct from given raw bytes(e.g: YAML, JSON, etc).

type SupportedTypes

type SupportedTypes interface {
	bool | string | int | float64
}

SupportedTypes is the generic type grouping that FeatureFlag can handle.

Jump to

Keyboard shortcuts

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