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 (*Layer) All ¶
All returns the entries of the given kind. The returned map must not be modified.
func (*Layer) IsEmpty ¶
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 ¶
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 ¶
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 ¶
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.