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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientFactoryFunc ¶
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 func(sdkKey config.SDKKey, config ld.Config) (*ld.LDClient, error)) 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.
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. 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, ) (interfaces.DataStoreFactory, 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 Kind ¶
type Kind string
Kind represents any of the supported SDK categories that has distinct behavior from the others.
const ( // Server represents server-side SDKs, which use server-side endpoints and authenticate their requests // with an SDK key. Server Kind = "server" // Mobile represents mobile SDKs, which use mobile endpoints and authenticate their requests with a // mobile key. Mobile Kind = "mobile" // JSClient represents client-side JavaScript-based SDKs, which use client-side endpoints and // authenticate their requests insecurely with an environment ID. JSClient Kind = "js" )
func (Kind) GetCredential ¶
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.
type LDClientContext ¶
type LDClientContext interface { Initialized() bool SecureModeHash(lduser.User) 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.
func DefaultClientFactory ¶
DefaultClientFactory is the default ClientFactoryFunc implementation, which just passes the specified configuration to the SDK client constructor.