filedata

package
v7.5.3 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: 22 Imported by: 0

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,
	retryInterval time.Duration,
	loggers ldlog.Loggers,
) (*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 UpdateHandler

type UpdateHandler interface {
	// AddEnvironment is called when the file data has provided a configuration for an environment
	// that ArchiveManager has not seen before.
	AddEnvironment(env ArchiveEnvironment)

	// UpdateEnvironment is called when a change in the file data has provided a new configuration
	// for an existing environment.
	UpdateEnvironment(env ArchiveEnvironment)

	// 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