bigsegments

package
v8.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package bigsegments contains logic for synchronizing big segments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BigSegmentStore

type BigSegmentStore interface {
	io.Closer

	// GetSynchronizedOn returns the synchronization time from the external store.
	//
	// The synchronization time may not exist in the store. Use `IsDefined()` to
	// check the result.
	GetSynchronizedOn() (ldtime.UnixMillisecondTime, error)
	// contains filtered or unexported methods
}

BigSegmentStore is the interface for interacting with an external big segment store. Each instance is specific to one LD environment.

func DefaultBigSegmentStoreFactory

func DefaultBigSegmentStoreFactory(
	envConfig config.EnvConfig,
	allConfig config.Config,
	loggers ldlog.Loggers,
) (BigSegmentStore, error)

DefaultBigSegmentStoreFactory implements our standard logic for optionally creating a BigSegmentStore.

func NewNullBigSegmentStore

func NewNullBigSegmentStore() BigSegmentStore

NewNullBigSegmentStore returns a no-op stub implementation. This is used only in tests, but it is exported from this package so that we can keep the interface methods private.

type BigSegmentStoreFactory

type BigSegmentStoreFactory func(
	envConfig config.EnvConfig,
	allConfig config.Config,
	loggers ldlog.Loggers,
) (BigSegmentStore, error)

BigSegmentStoreFactory creates an implementation of BigSegmentStore, if the configuration implies that we should have one; if not, it returns nil.

type BigSegmentSynchronizer

type BigSegmentSynchronizer interface {
	// Start begins synchronization of an environment.
	//
	// This method does not block.
	//
	// If the BigSegmentSynchronizer has already been started, or has been closed, this has no effect.
	Start()

	// HasSynced returns true if the synchronizer has ever successfully synced the data.
	//
	// We use this to determine whether Relay's internal SDK instances should bother trying to query
	// big segments metadata. If we haven't yet written any metadata, then trying to do so would
	// produce useless errors.
	HasSynced() bool

	// SegmentUpdatesCh returns a channel for notifications about segment data updates.
	//
	// Each value posted to this channel represents a batch of updates that the synchronizer has
	// applied. The caller is responsible for reading the channel to avoid blocking the
	// synchronizer.
	SegmentUpdatesCh() <-chan UpdatesSummary

	// Close ends synchronization of an environment.
	//
	// This method does not block.
	//
	// The BigSegmentSynchronizer cannot be restarted after calling Close.
	Close()
}

BigSegmentSynchronizer synchronizes big segment state for a given environment.

func DefaultBigSegmentSynchronizerFactory

func DefaultBigSegmentSynchronizerFactory(
	httpConfig httpconfig.HTTPConfig,
	store BigSegmentStore,
	pollURI string,
	streamURI string,
	envID config.EnvironmentID,
	sdkKey config.SDKKey,
	loggers ldlog.Loggers,
	logPrefix string,
) BigSegmentSynchronizer

DefaultBigSegmentSynchronizerFactory creates the default implementation of BigSegmentSynchronizer.

type BigSegmentSynchronizerFactory

type BigSegmentSynchronizerFactory func(
	httpConfig httpconfig.HTTPConfig,
	store BigSegmentStore,
	pollURI string,
	streamURI string,
	envID config.EnvironmentID,
	sdkKey config.SDKKey,
	loggers ldlog.Loggers,
	logPrefix string,
) BigSegmentSynchronizer

BigSegmentSynchronizerFactory creates an implementation of BigSegmentSynchronizer. We only use a single implementation in real life, but this allows us to use a mock one in tests. Calling the factory does not automatically start the synchronizer.

type UpdatesSummary

type UpdatesSummary struct {
	// SegmentKeysUpdated is a slice of segment keys (plain keys as used by the SDK-- not segment
	// IDs, i.e. there is no generation suffix).
	SegmentKeysUpdated []string
}

UpdatesSummary describes a batch of updates that the synchronizer has applied.

Jump to

Keyboard shortcuts

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