datasource

package
v7.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package datasource is an internal package containing implementation types for the SDK's data source implementations (streaming, polling, etc.) and related functionality. These types are not visible from outside of the SDK.

This does not include the file data source, which is in the ldfiledata package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDataSourceStatusProviderImpl

func NewDataSourceStatusProviderImpl(
	broadcaster *internal.Broadcaster[interfaces.DataSourceStatus],
	dataSourceUpdates *DataSourceUpdateSinkImpl,
) interfaces.DataSourceStatusProvider

NewDataSourceStatusProviderImpl creates the internal implementation of DataSourceStatusProvider.

func NewNullDataSource

func NewNullDataSource() subsystems.DataSource

NewNullDataSource returns a stub implementation of DataSource.

Types

type DataSourceUpdateSinkImpl

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

DataSourceUpdateSinkImpl is the internal implementation of DataSourceUpdateSink. It is exported because the actual implementation type, rather than the interface, is required as a dependency of other SDK components.

func NewDataSourceUpdateSinkImpl

func NewDataSourceUpdateSinkImpl(
	store subsystems.DataStore,
	dataStoreStatusProvider intf.DataStoreStatusProvider,
	dataSourceStatusBroadcaster *internal.Broadcaster[intf.DataSourceStatus],
	flagChangeEventBroadcaster *internal.Broadcaster[intf.FlagChangeEvent],
	logDataSourceOutageAsErrorAfter time.Duration,
	loggers ldlog.Loggers,
) *DataSourceUpdateSinkImpl

NewDataSourceUpdateSinkImpl creates the internal implementation of DataSourceUpdateSink.

func (*DataSourceUpdateSinkImpl) GetDataStoreStatusProvider

func (d *DataSourceUpdateSinkImpl) GetDataStoreStatusProvider() intf.DataStoreStatusProvider

func (*DataSourceUpdateSinkImpl) GetEnvironmentID added in v7.13.0

func (d *DataSourceUpdateSinkImpl) GetEnvironmentID() ldvalue.OptionalString

func (*DataSourceUpdateSinkImpl) GetLastStatus

func (d *DataSourceUpdateSinkImpl) GetLastStatus() intf.DataSourceStatus

GetLastStatus is used internally by SDK components.

func (*DataSourceUpdateSinkImpl) Init

func (d *DataSourceUpdateSinkImpl) Init(allData []st.Collection) bool

func (*DataSourceUpdateSinkImpl) SetEnvironmentID added in v7.13.0

func (d *DataSourceUpdateSinkImpl) SetEnvironmentID(environmentID ldvalue.OptionalString)

func (*DataSourceUpdateSinkImpl) UpdateStatus

func (d *DataSourceUpdateSinkImpl) UpdateStatus(
	newState intf.DataSourceState,
	newError intf.DataSourceErrorInfo,
)

func (*DataSourceUpdateSinkImpl) Upsert

func (d *DataSourceUpdateSinkImpl) Upsert(
	kind st.DataKind,
	key string,
	item st.ItemDescriptor,
) bool

type FailureClass added in v7.16.0

type FailureClass int

FailureClass categorizes a data source failure. No failure is permanently terminal: every failure is either "normal" (regular backoff and retry) or "unexpected" (extended backoff via a longer retry profile or wait interval, still retrying indefinitely).

const (
	// FailureClassNormal indicates a failure that a caller should treat as an
	// ordinary transient error.
	FailureClassNormal FailureClass = iota
	// FailureClassUnexpected indicates a failure that the caller should treat as
	// signalling a durable, non-transient upstream problem.
	FailureClassUnexpected
)

type PollingConfig

type PollingConfig struct {
	BaseURI                     string
	PollInterval                time.Duration
	FilterKey                   string
	ExtendedInitialPollInterval time.Duration
}

PollingConfig describes the configuration for a polling data source. It is exported so that it can be used in the PollingDataSourceBuilder.

type PollingProcessor

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

PollingProcessor is the internal implementation of the polling data source.

This type is exported from internal so that the PollingDataSourceBuilder tests can verify its configuration. All other code outside of this package should interact with it only via the DataSource interface.

func NewPollingProcessor

func NewPollingProcessor(
	context subsystems.ClientContext,
	dataSourceUpdates subsystems.DataSourceUpdateSink,
	cfg PollingConfig,
) *PollingProcessor

NewPollingProcessor creates the internal implementation of the polling data source.

func (*PollingProcessor) Close

func (pp *PollingProcessor) Close() error

func (*PollingProcessor) GetBaseURI

func (pp *PollingProcessor) GetBaseURI() string

GetBaseURI returns the configured polling base URI, for testing.

func (*PollingProcessor) GetFilterKey

func (pp *PollingProcessor) GetFilterKey() string

GetFilterKey returns the configured filter key, for testing.

func (*PollingProcessor) GetPollInterval

func (pp *PollingProcessor) GetPollInterval() time.Duration

GetPollInterval returns the configured polling interval, for testing.

func (*PollingProcessor) IsInitialized

func (pp *PollingProcessor) IsInitialized() bool

func (*PollingProcessor) Start

func (pp *PollingProcessor) Start(closeWhenReady chan<- struct{})

type PollingRequester added in v7.10.2

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

PollingRequester is the internal implementation of getting flag/segment data from the LD polling endpoints.

func NewPollingRequester added in v7.10.2

func NewPollingRequester(
	context subsystems.ClientContext,
	httpClient *http.Client,
	baseURI string,
	filterKey string,
) *PollingRequester

NewPollingRequester creates a new PollingRequester instance. This is for internal use only and should not be relied upon by consumers.

func (*PollingRequester) BaseURI added in v7.10.2

func (r *PollingRequester) BaseURI() string

BaseURI returns the base URI used for the polling request.

func (*PollingRequester) FilterKey added in v7.10.2

func (r *PollingRequester) FilterKey() string

FilterKey returns the filter key used for the polling request.

func (*PollingRequester) Request added in v7.10.2

Request makes a request to the LaunchDarkly polling endpoint for feature flag updates. It returns the data in the form of a slice of ldstoretypes.Collection. The boolean return value indicates whether the data was served from the cache. If an error occurs, it will be returned as the third return value.

type Requester

type Requester interface {
	Request() (data []ldstoretypes.Collection, cached bool, headers http.Header, err error)
	BaseURI() string
	FilterKey() string
}

Requester allows PollingProcessor to delegate fetching data to another component. This is useful for testing the PollingProcessor without needing to set up a test HTTP server.

type StreamConfig

type StreamConfig struct {
	URI                           string
	FilterKey                     string
	InitialReconnectDelay         time.Duration
	ExtendedInitialReconnectDelay time.Duration
	RetryResetInterval            time.Duration
}

StreamConfig describes the configuration for a streaming data source. It is exported so that it can be used in the StreamingDataSourceBuilder.

type StreamProcessor

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

StreamProcessor is the internal implementation of the streaming data source.

This type is exported from internal so that the StreamingDataSourceBuilder tests can verify its configuration. All other code outside of this package should interact with it only via the DataSource interface.

func NewStreamProcessor

func NewStreamProcessor(
	context subsystems.ClientContext,
	dataSourceUpdates subsystems.DataSourceUpdateSink,
	cfg StreamConfig,
) *StreamProcessor

NewStreamProcessor creates the internal implementation of the streaming data source.

func (*StreamProcessor) Close

func (sp *StreamProcessor) Close() error

func (*StreamProcessor) GetBaseURI

func (sp *StreamProcessor) GetBaseURI() string

GetBaseURI returns the configured streaming base URI, for testing.

func (*StreamProcessor) GetFilterKey

func (sp *StreamProcessor) GetFilterKey() string

GetFilterKey returns the configured key, for testing.

func (*StreamProcessor) GetInitialReconnectDelay

func (sp *StreamProcessor) GetInitialReconnectDelay() time.Duration

GetInitialReconnectDelay returns the configured reconnect delay, for testing.

func (*StreamProcessor) IsInitialized

func (sp *StreamProcessor) IsInitialized() bool

func (*StreamProcessor) Start

func (sp *StreamProcessor) Start(closeWhenReady chan<- struct{})

Jump to

Keyboard shortcuts

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