runtime

package
v1.27.13 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: BSD-3-Clause Imports: 13 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

This section is empty.

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 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 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