ldstoreimpl

package
v5.4.0-alpha.bigsegmen... Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Overview

Package ldstoreimpl contains SDK data store implementation objects that may be used by external code such as custom data store integrations and internal LaunchDarkly components. Application code normally will not use this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllKinds

func AllKinds() []ldstoretypes.DataKind

AllKinds returns a list of supported StoreDataKinds. Among other things, this list might be used by data stores to know what data (namespaces) to expect.

func Features

func Features() ldstoretypes.DataKind

Features returns the StoreDataKind instance corresponding to feature flag data.

func NewBigSegmentMembershipFromSegmentRefs added in v5.5.0

func NewBigSegmentMembershipFromSegmentRefs(
	includedSegmentRefs []string,
	excludedSegmentRefs []string,
) interfaces.BigSegmentMembership

NewBigSegmentMembershipFromSegmentRefs creates a BigSegmentMembership based on the specified lists of included and excluded segment references. This method is intended to be used by big segment store implementations; application code does not need to use it.

As described in interfaces.BigSegmentMembership, a segmentRef is not the same as the key property in the segment data model; it includes the key but also versioning information that the SDK will provide. The store implementation should not be concerned with the format of this.

The returned object's CheckMembership method will return ldvalue.NewOptionalBool(true) for any segmentRef that is in the included list, ldvalue.NewOptionalBool(false) for any segmentRef that is in the excluded list and *not* also in the included list, and ldvalue.OptionalBool{} (undefined) for all others.

The exact implementation type of the returned value may vary, to provide the most efficient representation of the data.

func NewDataStoreEvaluatorDataProvider

func NewDataStoreEvaluatorDataProvider(store interfaces.DataStore, loggers ldlog.Loggers) ldeval.DataProvider

NewDataStoreEvaluatorDataProvider provides an adapter for using a DataStore with the Evaluator type in go-server-sdk-evaluation.

Normal use of the SDK does not require this type. It is provided for use by other LaunchDarkly components that use DataStore and Evaluator separately from the SDK.

func NewUnboundedSegmentMembershipFromKeys

func NewUnboundedSegmentMembershipFromKeys(
	includedKeys []string,
	excludedKeys []string,
) interfaces.UnboundedSegmentMembership

NewUnboundedSegmentMembershipFromKeys creates an UnboundedSegmentMembership based on the specified lists of included and excluded keys. This method is intended to be used by unbounded segment store implementations; application code does not need to use it.

The returned object's CheckMembership method will return ldvalue.NewOptionalBool(true) for any key that is in the included list, ldvalue.NewOptionalBool(false) for any key that is in the excluded list and *not* also in the included list, and ldvalue.OptionalBool{} (undefined) for all other keys.

The exact implementation type of the returned value may vary, to provide the most efficient representation of the data.

func Segments

func Segments() ldstoretypes.DataKind

Segments returns the StoreDataKind instance corresponding to user segment data.

Types

type BigSegmentStoreWrapper added in v5.5.0

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

BigSegmentStoreWrapper is a component that adds status polling and caching to a BigSegmentStore, and provides integration with the evaluation engine.

This component is exposed in the SDK's public API because it needs to be used by the LaunchDarkly Relay Proxy as well (or any other component that is calling the evaluation engine in go-server-sdk-evaluation directly and needs to provide the same big segment functionality as the SDK). It implements the BigSegmentProvider interface that go-server-sdk-evaluation uses to query big segments (similar to how ldstoreimpl.NewDataStoreEvaluatorDataProvider provides an implementation of the DataProvider interface). It is also responsible for caching membership queries and polling the store's metadata to make sure it is not stale.

To avoid unnecessarily exposing implementation details that are subject to change, this type should not have any public methods other than GetUserMembership, GetStatus, and Close.

func NewBigSegmentStoreWrapper added in v5.5.0

func NewBigSegmentStoreWrapper(
	store interfaces.BigSegmentStore,
	statusUpdateFn func(interfaces.BigSegmentStoreStatus),
	pollInterval time.Duration,
	staleTime time.Duration,
	userCacheSize int,
	userCacheTime time.Duration,
	loggers ldlog.Loggers,
) *BigSegmentStoreWrapper

NewBigSegmentStoreWrapper creates a BigSegmentStoreWrapper and starts polling the store's status.

The BigSegmentStoreWrapper takes ownership of the BigSegmentStore's lifecycle at this point, so calling Close on the BigSegmentStoreWrapper will also close the store.

If not nil, statusUpdateFn will be called whenever the store status has changed.

func (*BigSegmentStoreWrapper) Close added in v5.5.0

func (w *BigSegmentStoreWrapper) Close()

Close shuts down the manager, the store, and the polling task.

func (*BigSegmentStoreWrapper) GetStatus added in v5.5.0

GetStatus returns a BigSegmentStoreStatus describing whether the store seems to be available (that is, the last query to it did not return an error) and whether it is stale (that is, the last known update time is too far in the past).

If we have not yet obtained that information (the poll task has not executed yet), then this method immediately does a metadata query and waits for it to succeed or fail. This means that if an application using big segments evaluates a feature flag immediately after creating the SDK client, before the first status poll has happened, that evaluation may block for however long it takes to query the store.

func (*BigSegmentStoreWrapper) GetUserMembership added in v5.5.0

GetUserMembership is called by the evaluator when it needs to get the big segment membership state for a user.

If there is a cached membership state for the user, it returns the cached state. Otherwise, it converts the user key into the hash string used by the BigSegmentStore, queries the store, and caches the result. The returned status value indicates whether the query succeeded, and whether the result (regardless of whether it was from a new query or the cache) should be considered "stale".

Jump to

Keyboard shortcuts

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