filedata

package
v9.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filedata contains logic for reading a file data source.

This abstracts away the implementation details so that the Relay implementation only needs to know what environments it should add, update, or remove.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveEnvironment

type ArchiveEnvironment struct {
	// Params contains all the properties necessary to create or update the environment, except for
	// the SDK data.
	Params envfactory.EnvironmentParams

	// SDKData contains the flags/segments/etc. for populating this environment, in the same format
	// used by the SDK.
	//
	// When updating an environment, if this field is nil, it means that the SDK data for the
	// environment has not changed and only the other environment properties should be updated.
	SDKData []ldstoretypes.Collection
}

ArchiveEnvironment describes both the environment properties and the SDK data for the environment.

type ArchiveManager

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

ArchiveManager manages the file data source.

That includes reading and unarchiving the data file, watching for changes to the file, and maintaining the last known state of the data so that it can determine what environmennts if any are affected by a change.

Relay provides an implementation of the UpdateHandler interface which will be called for all changes that it needs to know about.

func NewArchiveManager

func NewArchiveManager(
	filePath string,
	handler UpdateHandler,
	monitoringInterval time.Duration,
	logger *slog.Logger,
) (*ArchiveManager, error)

NewArchiveManager creates the ArchiveManager instance and attempts to read the initial file data.

If successful, it calls handler.AddEnvironment() for each environment configured in the file, and also starts a file watcher to detect updates to the file.

func (*ArchiveManager) Close

func (am *ArchiveManager) Close() error

Close shuts down the ArchiveManager.

type ArchiveManagerInterface

type ArchiveManagerInterface interface {
	io.Closer
}

ArchiveManagerInterface is an interface containing the public methods of ArchiveManager. This is used for test stubbing.

type OfflineModeData added in v9.0.1

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

OfflineModeData holds the current archive data. It outlives the synchronizers that read it: the SDK can close a synchronizer and build a new one later, and each new synchronizer reads the current data from here.

func NewOfflineModeData added in v9.0.1

func NewOfflineModeData(initialData []ldstoretypes.Collection) *OfflineModeData

NewOfflineModeData creates the data holder from the archive's initial data.

func (*OfflineModeData) UpdateData added in v9.0.1

func (d *OfflineModeData) UpdateData(collections []ldstoretypes.Collection) error

UpdateData allows external updates to the data (e.g., when the archive file changes).

type OfflineModeSynchronizer

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

OfflineModeSynchronizer implements subsystems.DataSynchronizer for offline mode. It loads pre-populated data from the archive file without connecting to LaunchDarkly.

func (*OfflineModeSynchronizer) Close

func (s *OfflineModeSynchronizer) Close() error

func (*OfflineModeSynchronizer) Fetch

Fetch returns the current basis (full dataset) from the offline data source.

func (*OfflineModeSynchronizer) Name

func (s *OfflineModeSynchronizer) Name() string

func (*OfflineModeSynchronizer) Sync

Sync starts the synchronizer and returns a channel for receiving updates. For offline mode, this immediately provides the data from the archive file.

type OfflineModeSynchronizerFactory

type OfflineModeSynchronizerFactory struct {
	Data *OfflineModeData
}

OfflineModeSynchronizerFactory creates a synchronizer that loads data from an external source (the relay's archive file) without making any network connections.

func (OfflineModeSynchronizerFactory) Build

Build returns a new synchronizer each time. Close ends a synchronizer permanently, and the SDK can build the synchronizer again after it closes it.

type UpdateHandler

type UpdateHandler interface {
	// AddEnvironment is called when the file data has provided a configuration for an environment
	// that ArchiveManager has not seen before. It returns an error if it refused the environment, so
	// ArchiveManager does not record the archive's version as applied.
	AddEnvironment(env ArchiveEnvironment) error

	// UpdateEnvironment is called when a change in the file data has provided a new configuration
	// for an existing environment. It returns an error if it refused the update. See AddEnvironment.
	UpdateEnvironment(env ArchiveEnvironment) error

	// EnvironmentFailed is called when the ArchiveManager was unable to load the data for an
	// environment.
	EnvironmentFailed(id config.EnvironmentID, err error)

	// DeleteEnvironment is called when a change in the file data has removed an environment.
	DeleteEnvironment(id config.EnvironmentID)
}

UpdateHandler defines the methods that ArchiveManager will call after processing new or updated file data.

Jump to

Keyboard shortcuts

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