memorystorev2

package
v7.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package memorystorev2 contains an implementation for a transactional memory store suitable for the FDv2 architecture.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store provides an abstraction that makes flag and segment data available to other components. It accepts updates in batches - for instance, flag A was upserted while segment B was deleted - such that the contents of the store are consistent with a single payload version at any given time.

The terminology used is "basis" and "deltas". First, the store's basis is set. This is this initial data, upon which subsequent deltas will be applied. Whenever the basis is set, any existing data is discarded.

Deltas are then applied to the store. A single delta update transforms the contents of the store atomically.

func New

func New(loggers ldlog.Loggers) *Store

New creates a new Store. The Store is uninitialized until SetBasis is called.

func (*Store) ApplyDelta

func (s *Store) ApplyDelta(allData []ldstoretypes.Collection) map[ldstoretypes.DataKind]map[string]bool

ApplyDelta applies a delta update to the store. ApplyDelta should not be called until SetBasis has been called at least once. The return value indicates, for each DataKind present in the delta, whether the item in the delta was actually updated or not.

An item is updated only if the version of the item in the delta is greater than the version in the store, or it wasn't already present.

func (*Store) Get

Get retrieves an item of the specified kind from the store. If the item is not found, then ItemDescriptor{}.NotFound() is returned with a nil error.

func (*Store) GetAll

GetAll retrieves all items of the specified kind from the store.

func (*Store) GetAllKinds

func (s *Store) GetAllKinds() []ldstoretypes.Collection

GetAllKinds retrieves all items of all kinds from the store. This is different from calling GetAll for each kind because it provides a consistent view of the entire store at a single point in time.

func (*Store) IsInitialized

func (s *Store) IsInitialized() bool

IsInitialized returns true if the store has ever been initialized with a basis.

func (*Store) SetBasis

func (s *Store) SetBasis(allData []ldstoretypes.Collection)

SetBasis sets the basis of the Store. Any existing data is discarded. When the basis is set, the store becomes initialized.

Jump to

Keyboard shortcuts

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