overrides

package
v7.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package overrides implements the flag/segment override layer. The layer is a runtime-mutable collection of flag and segment definitions, supplied by an override source. Those definitions take precedence over LaunchDarkly data at evaluation time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

type Layer struct {
	// contains filtered or unexported fields
}

Layer is a thread-safe store of override entries, replaced wholesale on each update from an override source.

func NewLayer

func NewLayer() *Layer

NewLayer creates an empty Layer.

func (*Layer) All

func (l *Layer) All(kind st.DataKind) map[string]st.ItemDescriptor

All returns the entries of the given kind. The returned map must not be modified.

func (*Layer) Get

func (l *Layer) Get(kind st.DataKind, key string) (st.ItemDescriptor, bool)

Get returns the override entry for a key, if any.

func (*Layer) IsEmpty

func (l *Layer) IsEmpty() bool

IsEmpty reports whether the layer contains no entries. It is a single atomic read, so the per-evaluation cost of a configured-but-unpopulated override layer is negligible.

func (*Layer) SetAll

func (l *Layer) SetAll(data []st.Collection) (previous, current layerContents)

SetAll atomically replaces the entire layer contents. An empty or nil slice clears the layer.

Each flag or segment is stored as a marked shallow copy. The copy shares its nested slices with the caller's entity, and the layer never writes to them. The caller's value is never marked. A source may retain the entities it supplied and supply them again. It must not modify them after it supplied them.

Returns the previous and new contents. The returned maps must not be modified.

type Overlay

type Overlay struct {
	// contains filtered or unexported fields
}

Overlay merges an override Layer over a base store. A read for a key returns the override entry when one exists, and the base entry otherwise. The overlay sits at the store read boundary. That placement makes targeting rules, prerequisites, and segment matches behave identically for overridden and ordinary data. They are the same reads through the same boundary.

func NewOverlay

func NewOverlay(base subsystems.ReadOnlyStore, layer *Layer) *Overlay

NewOverlay creates an Overlay over the given base store and layer.

func (*Overlay) Get

func (o *Overlay) Get(kind st.DataKind, key string) (st.ItemDescriptor, error)

Get returns the override entry for the key if one exists, and otherwise delegates to the base store. This works even when the base store is uninitialized, because an uninitialized base reports not-found rather than failing.

func (*Overlay) GetAll

func (o *Overlay) GetAll(kind st.DataKind) ([]st.KeyedItemDescriptor, error)

GetAll returns the union of the base store's items and the layer's items. The override entry wins for any key present in both. This includes keys the base holds as deleted-item tombstones.

When the base store fails and the layer holds entries, the result is the layer's entries alone, with no error. A per-key read serves those entries whatever the state of the base, so an all-flags read does the same. When the layer is empty, the base error is returned.

func (*Overlay) IsInitialized

func (o *Overlay) IsInitialized() bool

IsInitialized delegates to the base store: the override layer never affects initialization status or data availability.

type Sink

type Sink struct {
	// contains filtered or unexported fields
}

Sink applies override layer replacements supplied by an override source, and notifies flag-change listeners of the flags affected by each replacement.

func NewSink

func NewSink(
	layer *Layer,
	base subsystems.ReadOnlyStore,
	notify func(flagKey string),
	hasListeners func() bool,
	loggers ldlog.Loggers,
) *Sink

NewSink creates a Sink that writes to the given layer. base is the raw store holding LaunchDarkly data, without the overlay: merged-view snapshots for change computation are built from it plus the layer. The notify and hasListeners callbacks connect the sink to the owner's flag-change broadcaster without this package depending on it.

func (*Sink) SetOverrides

func (s *Sink) SetOverrides(data []st.Collection)

SetOverrides atomically replaces the entire override layer, then notifies listeners of every flag whose merged-view evaluation may have changed. Calls are serialized, so overlapping updates from a source cannot interleave.

Jump to

Keyboard shortcuts

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