envfactory

package
v8.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package envfactory contains types related to service-driven environment configuration, shared by the autoconfig and filedata packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToTime added in v8.8.0

func ToTime(millisecondTime ldtime.UnixMillisecondTime) time.Time

Types

type EnvConfigFactory

type EnvConfigFactory struct {
	// DataStorePrefix is the configured data store prefix, which may contain a per-environment placeholder.
	DataStorePrefix string
	// DataStorePrefix is the configured data store table name, which may contain a per-environment placeholder.
	TableName     string
	AllowedOrigin ct.OptStringList
	AllowedHeader ct.OptStringList
	// Whether this factory is used for offline mode or not.
	Offline bool
}

EnvConfigFactory is an abstraction of the logic for generating environment configurations that are partly parameterized, instead of each environment being manually configured. This is used in both auto-configuration mode and offline mode.

func NewEnvConfigFactoryForAutoConfig

func NewEnvConfigFactoryForAutoConfig(c config.AutoConfigConfig) EnvConfigFactory

NewEnvConfigFactoryForAutoConfig creates an EnvConfigFactory based on the auto-configuration mode settings.

func NewEnvConfigFactoryForOfflineMode

func NewEnvConfigFactoryForOfflineMode(c config.OfflineModeConfig) EnvConfigFactory

NewEnvConfigFactoryForOfflineMode creates an EnvConfigFactory based on the offline mode settings.

func (EnvConfigFactory) MakeEnvironmentConfig

func (f EnvConfigFactory) MakeEnvironmentConfig(params EnvironmentParams) config.EnvConfig

MakeEnvironmentConfig creates an EnvConfig based on both the individual EnvironmentParams and the properties of the EnvConfigFactory.

type EnvironmentParams

type EnvironmentParams struct {
	// ID is the environment ID.
	EnvID config.EnvironmentID

	// Identifiers contains the project and environment names and keys.
	Identifiers relayenv.EnvIdentifiers

	// SDKKey is the environment's SDK key; if there is more than one active key, it is the latest.
	SDKKey config.SDKKey

	// MobileKey is the environment's mobile key.
	MobileKey config.MobileKey

	// ExpiringSDKKey is an additional SDK key that should also be allowed (but not surfaced as
	// the canonical one).
	ExpiringSDKKey ExpiringSDKKey

	// TTL is the cache TTL for PHP clients.
	TTL time.Duration

	// SecureMode is true if secure mode is required for this environment.
	SecureMode bool
}

EnvironmentParams contains environment-specific information obtained from LaunchDarkly which will be used to configure a Relay environment in auto-configuration mode or offline mode.

This is a simplified representation that does not contain all of the properties used in the auto-configuration or offline mode protocols, but only the ones that the core Relay logic needs.

func (EnvironmentParams) WithFilter

type EnvironmentRep

type EnvironmentRep struct {
	EnvID      config.EnvironmentID `json:"envID"`
	EnvKey     string               `json:"envKey"`
	EnvName    string               `json:"envName"`
	MobKey     config.MobileKey     `json:"mobKey"`
	ProjKey    string               `json:"projKey"`
	ProjName   string               `json:"projName"`
	SDKKey     SDKKeyRep            `json:"sdkKey"`
	DefaultTTL int                  `json:"defaultTtl"`
	SecureMode bool                 `json:"secureMode"`
	Version    int                  `json:"version"`
}

EnvironmentRep is a representation of an environment that is being added or updated.

func (EnvironmentRep) Describe

func (r EnvironmentRep) Describe() string

func (EnvironmentRep) ID

func (r EnvironmentRep) ID() string

func (EnvironmentRep) ToParams

func (r EnvironmentRep) ToParams() EnvironmentParams

ToParams converts the JSON properties for an environment into our internal parameter type.

type ExpiringKeyRep

type ExpiringKeyRep struct {
	Value     config.SDKKey              `json:"value"`
	Timestamp ldtime.UnixMillisecondTime `json:"timestamp"`
}

ExpiringKeyRep describes an old key that will expire at the specified date/time.

func (ExpiringKeyRep) ToParams added in v8.8.0

func (e ExpiringKeyRep) ToParams() ExpiringSDKKey

type ExpiringSDKKey added in v8.8.0

type ExpiringSDKKey struct {
	Key        config.SDKKey
	Expiration time.Time
}

func (ExpiringSDKKey) Defined added in v8.8.0

func (e ExpiringSDKKey) Defined() bool

type FilterParams

type FilterParams struct {
	ProjKey string
	ID      config.FilterID
	Key     config.FilterKey
}

type FilterRep

type FilterRep struct {
	ProjKey   string           `json:"projKey"`
	FilterKey config.FilterKey `json:"key"`
	Version   int              `json:"version"`
}

func (FilterRep) Describe

func (f FilterRep) Describe() string

func (FilterRep) ToParams

func (f FilterRep) ToParams(id config.FilterID) FilterParams

ToParams converts the JSON properties for a filter into our internal parameter type. It requires an explicit FilterID because there is no ID included within the JSON representation.

func (FilterRep) ToTestParams

func (f FilterRep) ToTestParams() FilterParams

ToTestParams is similar to ToParams, but intended as a convenience for tests. It assumes that a filter's ID can be computed by concatenating the project key with the filter key.

type SDKKeyRep

type SDKKeyRep struct {
	Value    config.SDKKey  `json:"value"`
	Expiring ExpiringKeyRep `json:"expiring"`
}

SDKKeyRep describes an SDK key optionally accompanied by an old expiring key.

Jump to

Keyboard shortcuts

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