ldstoreimpl

package
v5.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 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 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 that are not strictly necessary for its use by the SDK and by the Relay Proxy.

func NewBigSegmentStoreWrapper deprecated 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.

Deprecated: This is superseded by NewBigSegmentStoreWrapperWithConfig.

func NewBigSegmentStoreWrapperWithConfig added in v5.6.0

func NewBigSegmentStoreWrapperWithConfig(
	config BigSegmentsConfigurationProperties,
	statusUpdateFn func(interfaces.BigSegmentStoreStatus),
	loggers ldlog.Loggers,
) *BigSegmentStoreWrapper

NewBigSegmentStoreWrapperWithConfig creates a BigSegmentStoreWrapper.

It also immediately begins polling the store status, unless config.StatusPollingInitiallyPaused is true.

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) ClearCache added in v5.6.0

func (w *BigSegmentStoreWrapper) ClearCache()

ClearCache invalidates the cache of per-user Big Segment state, so subsequent queries will get the latest data.

This is used by the Relay Proxy, but is not currently used by the SDK otherwise.

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

func (*BigSegmentStoreWrapper) SetPollingActive added in v5.6.0

func (w *BigSegmentStoreWrapper) SetPollingActive(active bool)

SetPollingActive switches the polling task on or off.

This is used by the Relay Proxy, but is not currently used by the SDK otherwise.

type BigSegmentsConfigurationProperties added in v5.6.0

type BigSegmentsConfigurationProperties struct {
	// Store the data store instance that is used for Big Segments data. If nil, Big Segments are disabled.
	Store interfaces.BigSegmentStore

	// UserCacheSize is the maximum number of users whose Big Segment state will be cached by the SDK
	// at any given time.
	UserCacheSize int

	// UserCacheTime is the maximum length of time that the Big Segment state for a user will be cached
	// by the SDK.
	UserCacheTime time.Duration

	// StatusPollInterval is the interval at which the SDK will poll the Big Segment store to make sure
	// it is available and to determine how long ago it was updated
	StatusPollInterval time.Duration

	// StaleAfter is the maximum length of time between updates of the Big Segments data before the data
	// is considered out of date.
	StaleAfter time.Duration

	// StartPolling is true if the polling task should be started immediately. Otherwise, it will only
	// start after calling BigSegmentsStoreWrapper.SetPollingActive(true). This property is always true
	// in regular use of the SDK; the Relay Proxy may set it to false.
	StartPolling bool
}

BigSegmentsConfigurationProperties encapsulates the SDK's configuration with regard to Big Segments.

This struct implements the BigSegmentsConfiguration interface, but allows for addition of new properties. In a future version, BigSegmentsConfigurationBuilder and other configuration builders may be changed to use concrete types instead of interfaces.

func (BigSegmentsConfigurationProperties) GetStaleAfter added in v5.6.0

func (BigSegmentsConfigurationProperties) GetStatusPollInterval added in v5.6.0

func (p BigSegmentsConfigurationProperties) GetStatusPollInterval() time.Duration

func (BigSegmentsConfigurationProperties) GetStore added in v5.6.0

func (BigSegmentsConfigurationProperties) GetUserCacheSize added in v5.6.0

func (p BigSegmentsConfigurationProperties) GetUserCacheSize() int

func (BigSegmentsConfigurationProperties) GetUserCacheTime added in v5.6.0

func (p BigSegmentsConfigurationProperties) GetUserCacheTime() time.Duration

Jump to

Keyboard shortcuts

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