Documentation ¶
Overview ¶
Package sdks contains types and helpers for describing the behavior of different kinds of SDKs that can connect to Relay, and also for Relay's own use of the Go SDK.
Index ¶
- func ConfigureBigSegments(allConfig config.Config, envConfig config.EnvConfig, loggers ldlog.Loggers) (subsystems.ComponentConfigurer[subsystems.BigSegmentsConfiguration], error)
- func GetCredential(k basictypes.SDKKind, req *http.Request) (credential.SDKCredential, error)
- func GetDynamoDBBasicProperties(dbConfig config.DynamoDBConfig, envConfig config.EnvConfig) (endpoint *string, tableName, prefix string)
- func GetRedisBasicProperties(dbConfig config.RedisConfig, envConfig config.EnvConfig) (redisURL, prefix string)
- func NewSimpleClientContext(sdkKey string, sdkConfig ld.Config) subsystems.ClientContext
- func ObscureKey(key string) string
- type ClientFactoryFunc
- type DataStoreEnvironmentInfo
- type DataStoreStatusInfo
- type LDClientConstructor
- type LDClientContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureBigSegments ¶
func ConfigureBigSegments( allConfig config.Config, envConfig config.EnvConfig, loggers ldlog.Loggers, ) (subsystems.ComponentConfigurer[subsystems.BigSegmentsConfiguration], error)
ConfigureBigSegments provides the appropriate Go SDK big segments configuration based on the Relay configuration, or nil if big segments are not enabled. The big segments stores in Relay's SDK instances are used for client-side evaluations; server-side SDKs will read from the same database via their own big segments stores, which will need to be configured similarly to what's here.
func GetCredential ¶
func GetCredential(k basictypes.SDKKind, req *http.Request) (credential.SDKCredential, error)
GetCredential attempts to get the appropriate kind of authentication credential for this SDK kind from an HTTP request. For Server and Mobile, this uses the Authorization header; for JSClient, it is in a path parameter.
func GetDynamoDBBasicProperties ¶
func GetDynamoDBBasicProperties( dbConfig config.DynamoDBConfig, envConfig config.EnvConfig, ) (endpoint *string, tableName, prefix string)
GetDynamoDBBasicProperties transforms the configuration properties to the standard parameters used for DynamoDB. This function is exported to ensure consistency between the SDK configuration and the internal big segment store for DynamoDB.
func GetRedisBasicProperties ¶
func GetRedisBasicProperties( dbConfig config.RedisConfig, envConfig config.EnvConfig, ) (redisURL, prefix string)
GetRedisBasicProperties transforms the configuration properties to the standard parameters used for Redis. This function is exported to ensure consistency between the SDK configuration and the internal big segment store for Redis.
func NewSimpleClientContext ¶
func NewSimpleClientContext(sdkKey string, sdkConfig ld.Config) subsystems.ClientContext
NewSimpleClientContext creates a simple implementation of the SDK's ClientContext interface for initializing SDK components. The SDK doesn't surface a way to do this because components aren't normally created outside of its own constructor.
func ObscureKey ¶
ObscureKey returns an obfuscated version of an SDK key or mobile key.
Types ¶
type ClientFactoryFunc ¶
type ClientFactoryFunc func(sdkKey config.SDKKey, config ld.Config, timeout time.Duration) (LDClientContext, error)
ClientFactoryFunc is a function that creates the LaunchDarkly client. This is normally DefaultClientFactory, but it can be changed in order to make configuration changes or for testing.
func ClientFactoryFromLDClientFactory ¶
func ClientFactoryFromLDClientFactory(fn LDClientConstructor) ClientFactoryFunc
ClientFactoryFromLDClientFactory translates from the client factory type that we expose to host applications, which uses the real LDClient type, to the more general factory type that we use internally which uses the sdks.ClientFactoryFunc abstraction. The latter makes our code a bit cleaner and easier to test, but isn't of any use when hosting Relay in an application.
func DefaultClientFactory ¶
func DefaultClientFactory() ClientFactoryFunc
DefaultClientFactory is the default ClientFactoryFunc implementation, which just passes the specified configuration to the SDK client constructor.
type DataStoreEnvironmentInfo ¶
type DataStoreEnvironmentInfo struct { // DBType is the type of database Relay is using, or "" for the default in-memory storage. DBType string // DBServer is the URL or host address of the database server, if applicable. Passwords, if any, // must be redacted in this string. DBServer string // DBPrefix is the key prefix used for this environment to distinguish it from data that might be in // the same database for other environments. This is required for Redis and Consul but optional for // DynamoDB. DBPrefix string // DBTable is the table name for this environment if using DynamoDB, or "" otherwise. DBTable string }
DataStoreEnvironmentInfo encapsulates database-related configuration details that we will expose in the status resource for a specific environment. Some of these are set on a per-environment basis and others are global.
func ConfigureDataStore ¶
func ConfigureDataStore( allConfig config.Config, envConfig config.EnvConfig, loggers ldlog.Loggers, ) (subsystems.ComponentConfigurer[subsystems.DataStore], DataStoreEnvironmentInfo, error)
ConfigureDataStore provides the appropriate Go SDK data store factory (in-memory, Redis, etc.) based on the Relay configuration. It can return an error for some invalid configurations, but it assumes that we have already done the standard validation steps defined in the config package.
type DataStoreStatusInfo ¶
type DataStoreStatusInfo struct { // Available is copied from interfaces.DataStoreStatus. Available bool // LastUpdated is the time when the status last changed. LastUpdated time.Time }
DataStoreStatusInfo combines the Available property from interfaces.DataStoreStatus with a timestamp.
type LDClientConstructor ¶
type LDClientConstructor func(sdkKey string, config ld.Config, timeout time.Duration) (*ld.LDClient, error)
LDClientConstructor is the function type of the underlying SDK client constructor.
type LDClientContext ¶
type LDClientContext interface { Initialized() bool SecureModeHash(ldcontext.Context) string GetDataSourceStatus() interfaces.DataSourceStatus GetDataStoreStatus() DataStoreStatusInfo Close() error }
LDClientContext defines a minimal interface for a LaunchDarkly client.
Once the SDK client has been created, Relay does not need to use most of the SDK API. This interface provides access to only the necessary methods. This also makes testing simpler, since the test code needs to mock only this interface.