store

package
v6.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package store contains the internal implementation of how Relay interacts with the SDK's DataStore to detect data updates.

This is an internal package; application code for specific Relay distributions should not need to reference it directly, only the core code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataStoreProvider

type DataStoreProvider interface {
	// GetStore returns the current data store, or nil if it has not been created.
	GetStore() interfaces.DataStore
}

DataStoreProvider is an interface implemented by SSERelayDataStoreAdapter, describing a component that may or may not yet have a data store.

type SSERelayDataStoreAdapter

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

SSERelayDataStoreAdapter is used to create the data store wrapper that manages updates. When data is updated in the underlying store, it calls methods of EnvStreams to broadcast the updates.

Because the SDK normally wants to manage the lifecycle of its components, it requires you to provide a factory for any custom component, rather than an instance of the component itself. Then it asks the factory to create the instance when the LDClient is created. However, in this case we want to be able to access the instance externally.

Also, since streamUpdatesStoreWrapper is a wrapper for an underlying data store that could be a database, we need to be able to specify which data store implementation is being used - also as a factory.

So, this factory implementation - which should only be used for a single client at a time - calls the wrapped factory to produce the underlying data store, then creates our own store instance, and then puts a reference to that instance inside itself where we can see it.

func NewSSERelayDataStoreAdapter

func NewSSERelayDataStoreAdapter(
	wrappedFactory interfaces.DataStoreFactory,
	updates streams.EnvStreamUpdates,
) *SSERelayDataStoreAdapter

NewSSERelayDataStoreAdapter creates a new instance where the store has not yet been created.

func (*SSERelayDataStoreAdapter) CreateDataStore

func (a *SSERelayDataStoreAdapter) CreateDataStore(
	context interfaces.ClientContext,
	dataStoreUpdates interfaces.DataStoreUpdates,
) (interfaces.DataStore, error)

CreateDataStore is called by the SDK when the LDClient is being created.

func (*SSERelayDataStoreAdapter) GetStore

GetStore returns the current data store, or nil if it has not been created.

func (*SSERelayDataStoreAdapter) GetUpdates added in v6.4.0

GetUpdates returns the EnvStreamUpdates that will receive all updates sent to this store. This is exposed for testing so that we can simulate receiving updates from LaunchDarkly to this component.

Jump to

Keyboard shortcuts

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