Documentation
¶
Overview ¶
Package envfactory contains types related to service-driven environment configuration, shared by the autoconfig and filedata packages.
Index ¶
- func BuildAcceptedSet(params EnvironmentParams) (credential.AcceptedSet, []string, error)
- func ToTime(millisecondTime ldtime.UnixMillisecondTime) time.Time
- type AcceptedMobileKey
- type AcceptedSDKKey
- type ConcurrentKeyRep
- type EnvConfigFactory
- type EnvironmentParams
- type EnvironmentRep
- type ExpiringKeyRep
- type FilterParams
- type FilterRep
- type SDKKeyRep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAcceptedSet ¶ added in v8.21.0
func BuildAcceptedSet(params EnvironmentParams) (credential.AcceptedSet, []string, error)
BuildAcceptedSet converts EnvironmentParams into the AcceptedSet that EnvContext.ReconcileCredentials needs. It is the single home for the anchor invariant, for both RAC and the offline archive.
Credential identity is the value (the secret), not the wire identifier, so a rename produces an unchanged AcceptedSet.
Expiry comes from the arrays. The legacy sdkKey.expiring wire slot is never consulted.
On a structurally malformed payload it returns a *credential.MalformedCredentialSetError and an empty set. The caller must keep the previous accepted state, and RAC handlers must also reconnect the stream with jitter.
It filters out keys scoped to a view and names them in the second return value, so callers can log what they dropped. An SDK presenting one gets a 401, because the key is absent from the lookup map.
Types ¶
type AcceptedMobileKey ¶ added in v8.21.0
AcceptedMobileKey is one entry in the accepted mobile key set for an environment. Expiry is zero if the key is permanent. HasViews is true if the mobile key is associated with a view.
type AcceptedSDKKey ¶ added in v8.21.0
AcceptedSDKKey is one entry in the accepted SDK key set for an environment. Expiry is zero if the key is permanent. HasViews is true if the SDK key is associated with a view.
type ConcurrentKeyRep ¶ added in v8.21.0
type ConcurrentKeyRep struct {
Key string `json:"key"`
Value string `json:"value"`
Expiry *int64 `json:"expiry,omitempty"` // Unix-ms; nil = permanent
HasViews bool `json:"hasViews"`
}
ConcurrentKeyRep is an entry in the sdkKeys or mobileKeys array on EnvironmentRep. It represents one accepted credential in an environment's concurrent key set. See EnvironmentRep for the wire vocabulary.
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 anchor SDK key (the wire's sdkKey.value).
SDKKey config.SDKKey
// MobileKey is the environment's mobile key.
MobileKey config.MobileKey
// AcceptedSDKKeys is the full accepted set of SDK keys, including the anchor. ToParams always
// leaves it non-nil, synthesizing from the singular sdkKey field when the payload has no
// sdkKeys array.
AcceptedSDKKeys []AcceptedSDKKey
// AcceptedMobileKeys is the full accepted set of mobile keys. ToParams always leaves it non-nil,
// synthesizing from the singular mobKey field when the payload has no mobileKeys array.
AcceptedMobileKeys []AcceptedMobileKey
// 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 ¶
func (e EnvironmentParams) WithFilter(key config.FilterKey) EnvironmentParams
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"`
SDKKeys []ConcurrentKeyRep `json:"sdkKeys,omitempty"`
MobileKeys []ConcurrentKeyRep `json:"mobileKeys,omitempty"`
DefaultTTL int `json:"defaultTtl"`
SecureMode bool `json:"secureMode"`
Version int `json:"version"`
}
EnvironmentRep is the wire shape of an environment, shared by RAC and the offline archive.
Wire vocabulary: "key" is the non-secret human-readable identifier; "value" is the credential secret. Relay's own SDKKey, MobileKey, and SDKCredential types hold what the wire calls "value". Do not rename them.
sdkKey and mobKey are the singular default credentials. sdkKey is an object because it also carries the legacy sdkKey.expiring slot; mobKey is a plain string because mobile keys never had one. sdkKeys and mobileKeys are the authoritative full accepted set, with entries of the form { key, value, expiry?, hasViews? }.
This parse path never sets DisallowUnknownFields, so a relay predating concurrent keys ignores sdkKeys and mobileKeys and keeps using sdkKey and mobKey.
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.
type FilterParams ¶
type FilterRep ¶
type FilterRep struct {
ProjKey string `json:"projKey"`
FilterKey config.FilterKey `json:"key"`
Version int `json:"version"`
}
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.