Documentation ¶
Overview ¶
Package ldcomponents provides the standard implementations and configuration options of LaunchDarkly components.
Some configuration options are represented as fields in the main Config struct; but others are specific to one area of functionality, such as how the SDK receives feature flag updates or processes analytics events. For the latter, the standard way to specify a configuration is to call one of the functions in ldcomponents (such as StreamingDataSource), apply any desired configuration change to the object that that method returns (such as StreamingDataSourceBuilder.InitialReconnectDelay), and then put the configured component builder into the corresponding Config field (such as Config.DataSource) to use that configuration in the SDK.
Index ¶
- Constants
- func ExternalUpdatesOnly() interfaces.DataSourceFactory
- func InMemoryDataStore() interfaces.DataStoreFactory
- func NoEvents() interfaces.EventProcessorFactory
- func NoLogging() interfaces.LoggingConfigurationFactory
- type EventProcessorBuilder
- func (b *EventProcessorBuilder) AllAttributesPrivate(value bool) *EventProcessorBuilder
- func (b *EventProcessorBuilder) BaseURI(baseURI string) *EventProcessorBuilder
- func (b *EventProcessorBuilder) Capacity(capacity int) *EventProcessorBuilder
- func (b *EventProcessorBuilder) CreateEventProcessor(context interfaces.ClientContext) (ldevents.EventProcessor, error)
- func (b *EventProcessorBuilder) DescribeConfiguration() ldvalue.Value
- func (b *EventProcessorBuilder) DiagnosticRecordingInterval(interval time.Duration) *EventProcessorBuilder
- func (b *EventProcessorBuilder) FlushInterval(interval time.Duration) *EventProcessorBuilder
- func (b *EventProcessorBuilder) InlineUsersInEvents(value bool) *EventProcessorBuilder
- func (b *EventProcessorBuilder) PrivateAttributeNames(attributes ...lduser.UserAttribute) *EventProcessorBuilder
- func (b *EventProcessorBuilder) UserKeysCapacity(userKeysCapacity int) *EventProcessorBuilder
- func (b *EventProcessorBuilder) UserKeysFlushInterval(interval time.Duration) *EventProcessorBuilder
- type HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) CACert(certData []byte) *HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) CACertFile(filePath string) *HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) ConnectTimeout(connectTimeout time.Duration) *HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) CreateHTTPConfiguration(basicConfiguration interfaces.BasicConfiguration) (interfaces.HTTPConfiguration, error)
- func (b *HTTPConfigurationBuilder) DescribeConfiguration() ldvalue.Value
- func (b *HTTPConfigurationBuilder) HTTPClientFactory(httpClientFactory func() *http.Client) *HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) ProxyURL(proxyURL string) *HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) UserAgent(userAgent string) *HTTPConfigurationBuilder
- func (b *HTTPConfigurationBuilder) Wrapper(wrapperName, wrapperVersion string) *HTTPConfigurationBuilder
- type LoggingConfigurationBuilder
- func (b *LoggingConfigurationBuilder) CreateLoggingConfiguration(basic interfaces.BasicConfiguration) (interfaces.LoggingConfiguration, error)
- func (b *LoggingConfigurationBuilder) LogDataSourceOutageAsErrorAfter(logDataSourceOutageAsErrorAfter time.Duration) *LoggingConfigurationBuilder
- func (b *LoggingConfigurationBuilder) LogEvaluationErrors(logEvaluationErrors bool) *LoggingConfigurationBuilder
- func (b *LoggingConfigurationBuilder) LogUserKeyInErrors(logUserKeyInErrors bool) *LoggingConfigurationBuilder
- func (b *LoggingConfigurationBuilder) Loggers(loggers ldlog.Loggers) *LoggingConfigurationBuilder
- func (b *LoggingConfigurationBuilder) MinLevel(level ldlog.LogLevel) *LoggingConfigurationBuilder
- type PersistentDataStoreBuilder
- func (b *PersistentDataStoreBuilder) CacheForever() *PersistentDataStoreBuilder
- func (b *PersistentDataStoreBuilder) CacheSeconds(cacheSeconds int) *PersistentDataStoreBuilder
- func (b *PersistentDataStoreBuilder) CacheTime(cacheTime time.Duration) *PersistentDataStoreBuilder
- func (b *PersistentDataStoreBuilder) CreateDataStore(context interfaces.ClientContext, dataStoreUpdates interfaces.DataStoreUpdates) (interfaces.DataStore, error)
- func (b *PersistentDataStoreBuilder) DescribeConfiguration() ldvalue.Value
- func (b *PersistentDataStoreBuilder) NoCaching() *PersistentDataStoreBuilder
- type PollingDataSourceBuilder
- func (b *PollingDataSourceBuilder) BaseURI(baseURI string) *PollingDataSourceBuilder
- func (b *PollingDataSourceBuilder) CreateDataSource(context interfaces.ClientContext, ...) (interfaces.DataSource, error)
- func (b *PollingDataSourceBuilder) DescribeConfiguration() ldvalue.Value
- func (b *PollingDataSourceBuilder) PollInterval(pollInterval time.Duration) *PollingDataSourceBuilder
- type StreamingDataSourceBuilder
- func (b *StreamingDataSourceBuilder) BaseURI(baseURI string) *StreamingDataSourceBuilder
- func (b *StreamingDataSourceBuilder) CreateDataSource(context interfaces.ClientContext, ...) (interfaces.DataSource, error)
- func (b *StreamingDataSourceBuilder) DescribeConfiguration() ldvalue.Value
- func (b *StreamingDataSourceBuilder) InitialReconnectDelay(initialReconnectDelay time.Duration) *StreamingDataSourceBuilder
Constants ¶
const ( // DefaultEventsBaseURI is the default value for EventProcessorBuilder.BaseURI. DefaultEventsBaseURI = "https://events.launchdarkly.com" // DefaultEventsCapacity is the default value for EventProcessorBuilder.Capacity. DefaultEventsCapacity = 10000 // DefaultDiagnosticRecordingInterval is the default value for EventProcessorBuilder.DiagnosticRecordingInterval. DefaultDiagnosticRecordingInterval = 15 * time.Minute // DefaultFlushInterval is the default value for EventProcessorBuilder.FlushInterval. DefaultFlushInterval = 5 * time.Second // DefaultUserKeysCapacity is the default value for EventProcessorBuilder.UserKeysCapacity. DefaultUserKeysCapacity = 1000 // DefaultUserKeysFlushInterval is the default value for EventProcessorBuilder.UserKeysFlushInterval. DefaultUserKeysFlushInterval = 5 * time.Minute // MinimumDiagnosticRecordingInterval is the minimum value for EventProcessorBuilder.DiagnosticRecordingInterval. MinimumDiagnosticRecordingInterval = 60 * time.Second )
const DefaultConnectTimeout = 3 * time.Second
DefaultConnectTimeout is the HTTP connection timeout that is used if HTTPConfigurationBuilder.ConnectTimeout is not set.
const DefaultInitialReconnectDelay = time.Second
DefaultInitialReconnectDelay is the default value for StreamingDataSourceBuilder.InitialReconnectDelay.
const DefaultLogDataSourceOutageAsErrorAfter = time.Minute
DefaultLogDataSourceOutageAsErrorAfter is the default value for LoggingConfigurationBuilder.LogDataSourceOutageAsErrorAfter(): one minute.
const DefaultPollInterval = 30 * time.Second
DefaultPollInterval is the default value for PollingDataSourceBuilder.PollInterval. This is also the minimum value.
const DefaultPollingBaseURI = "https://app.launchdarkly.com"
DefaultPollingBaseURI is the default value for PollingDataSourceBuilder.BaseURI.
const DefaultStreamingBaseURI = "https://stream.launchdarkly.com"
DefaultStreamingBaseURI is the default value for StreamingDataSourceBuilder.BaseURI.
const PersistentDataStoreDefaultCacheTime = 15 * time.Second
PersistentDataStoreDefaultCacheTime is the default amount of time that recently read or updated items will be cached in memory, if you use PersistentDataStore(). You can specify otherwise with the PersistentDataStoreBuilder.CacheTime() option.
Variables ¶
This section is empty.
Functions ¶
func ExternalUpdatesOnly ¶
func ExternalUpdatesOnly() interfaces.DataSourceFactory
ExternalUpdatesOnly returns a configuration object that disables a direct connection with LaunchDarkly for feature flag updates.
Storing this in LDConfig.DataSource causes the SDK not to retrieve feature flag data from LaunchDarkly, regardless of any other configuration. This is normally done if you are using the Relay Proxy (https://docs.launchdarkly.com/docs/the-relay-proxy) in "daemon mode", where an external process-- the Relay Proxy-- connects to LaunchDarkly and populates a persistent data store with the feature flag data. The data store could also be populated by another process that is running the LaunchDarkly SDK. If there is no external process updating the data store, then the SDK will not have any feature flag data and will return application default values only.
config := ld.Config{ DataSource: ldcomponents.ExternalUpdatesOnly(), }
func InMemoryDataStore ¶
func InMemoryDataStore() interfaces.DataStoreFactory
InMemoryDataStore returns the default in-memory DataStore implementation factory.
func NoEvents ¶
func NoEvents() interfaces.EventProcessorFactory
NoEvents returns a configuration object that disables analytics events.
Storing this in Config.Events causes the SDK to discard all analytics events and not send them to LaunchDarkly, regardless of any other configuration.
config := ld.Config{ Events: ldcomponents.NoEvents(), }
func NoLogging ¶
func NoLogging() interfaces.LoggingConfigurationFactory
NoLogging returns a configuration object that disables logging.
config := ld.Config{ Logging: ldcomponents.NoLogging(), }
Types ¶
type EventProcessorBuilder ¶
type EventProcessorBuilder struct {
// contains filtered or unexported fields
}
EventProcessorBuilder provides methods for configuring analytics event behavior.
See SendEvents for usage.
func SendEvents ¶
func SendEvents() *EventProcessorBuilder
SendEvents returns a configuration builder for analytics event delivery.
The default configuration has events enabled with default settings. If you want to customize this behavior, call this method to obtain a builder, change its properties with the EventProcessorBuilder methods, and store it in Config.Events:
config := ld.Config{ Events: ldcomponents.SendEvents().Capacity(5000).FlushInterval(2 * time.Second), }
To disable analytics events, use NoEvents instead of SendEvents.
func (*EventProcessorBuilder) AllAttributesPrivate ¶
func (b *EventProcessorBuilder) AllAttributesPrivate(value bool) *EventProcessorBuilder
AllAttributesPrivate sets or not all optional user attributes should be hidden from LaunchDarkly.
If this is true, all user attribute values (other than the key) will be private, not just the attributes specified with PrivateAttributeNames or on a per-user basis with UserBuilder methods. By default, it is false.
func (*EventProcessorBuilder) BaseURI ¶
func (b *EventProcessorBuilder) BaseURI(baseURI string) *EventProcessorBuilder
BaseURI sets a custom base URI for the events service.
You will only need to change this value in the following cases:
1. You are using the Relay Proxy (https://docs.launchdarkly.com/docs/the-relay-proxy). Set BaseURI to the base URI of the Relay Proxy instance.
2. You are connecting to a test server or anything else other than the standard LaunchDarkly service.
func (*EventProcessorBuilder) Capacity ¶
func (b *EventProcessorBuilder) Capacity(capacity int) *EventProcessorBuilder
Capacity sets the capacity of the events buffer.
The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the buffer is flushed (see FlushInterval), events will be discarded. Increasing the capacity means that events are less likely to be discarded, at the cost of consuming more memory.
The default value is DefaultEventsCapacity.
func (*EventProcessorBuilder) CreateEventProcessor ¶
func (b *EventProcessorBuilder) CreateEventProcessor( context interfaces.ClientContext, ) (ldevents.EventProcessor, error)
CreateEventProcessor is called by the SDK to create the event processor instance.
func (*EventProcessorBuilder) DescribeConfiguration ¶
func (b *EventProcessorBuilder) DescribeConfiguration() ldvalue.Value
DescribeConfiguration is used internally by the SDK to inspect the configuration.
func (*EventProcessorBuilder) DiagnosticRecordingInterval ¶
func (b *EventProcessorBuilder) DiagnosticRecordingInterval(interval time.Duration) *EventProcessorBuilder
DiagnosticRecordingInterval sets the interval at which periodic diagnostic data is sent.
The default value is DefaultDiagnosticRecordingInterval; the minimum value is MinimumDiagnosticRecordingInterval. This property is ignored if Config.DiagnosticOptOut is set to true.
func (*EventProcessorBuilder) FlushInterval ¶
func (b *EventProcessorBuilder) FlushInterval(interval time.Duration) *EventProcessorBuilder
FlushInterval sets the interval between flushes of the event buffer.
Decreasing the flush interval means that the event buffer is less likely to reach capacity (see Capacity).
The default value is DefaultFlushInterval.
func (*EventProcessorBuilder) InlineUsersInEvents ¶
func (b *EventProcessorBuilder) InlineUsersInEvents(value bool) *EventProcessorBuilder
InlineUsersInEvents sets whether to include full user details in every analytics event.
The default is false: events will only include the user key, except for one "index" event that provides the full details for the user.
func (*EventProcessorBuilder) PrivateAttributeNames ¶
func (b *EventProcessorBuilder) PrivateAttributeNames(attributes ...lduser.UserAttribute) *EventProcessorBuilder
PrivateAttributeNames marks a set of attribute names as always private.
Any users sent to LaunchDarkly with this configuration active will have attributes with these names removed. This is in addition to any attributes that were marked as private for an individual user with UserBuilder methods. Setting AllAttributePrivate to true overrides this.
config := ld.Config{ Events: ldcomponents.SendEvents(). PrivateAttributeNames(lduser.EmailAttribute, lduser.UserAttribute("some-custom-attribute")), }
func (*EventProcessorBuilder) UserKeysCapacity ¶
func (b *EventProcessorBuilder) UserKeysCapacity(userKeysCapacity int) *EventProcessorBuilder
UserKeysCapacity sets the number of user keys that the event processor can remember at any one time.
To avoid sending duplicate user details in analytics events, the SDK maintains a cache of recently seen user keys, expiring at an interval set by UserKeysFlushInterval.
The default value is DefaultUserKeysCapacity.
func (*EventProcessorBuilder) UserKeysFlushInterval ¶
func (b *EventProcessorBuilder) UserKeysFlushInterval(interval time.Duration) *EventProcessorBuilder
UserKeysFlushInterval sets the interval at which the event processor will reset its cache of known user keys.
The default value is DefaultUserKeysFlushInterval.
type HTTPConfigurationBuilder ¶
type HTTPConfigurationBuilder struct {
// contains filtered or unexported fields
}
HTTPConfigurationBuilder contains methods for configuring the SDK's networking behavior.
If you want to set non-default values for any of these properties, create a builder with ldcomponents.HTTPConfiguration(), change its properties with the HTTPConfigurationBuilder methods, and store it in Config.HTTP:
config := ld.Config{ HTTP: ldcomponents.HTTPConfiguration(). ConnectTimeout(3 * time.Second). ProxyURL(proxyUrl), }
func HTTPConfiguration ¶
func HTTPConfiguration() *HTTPConfigurationBuilder
HTTPConfiguration returns a configuration builder for the SDK's HTTP configuration.
config := ld.Config{ HTTP: ldcomponents.HTTPConfiguration(). ConnectTimeout(3 * time.Second). ProxyURL(proxyUrl), }
func (*HTTPConfigurationBuilder) CACert ¶
func (b *HTTPConfigurationBuilder) CACert(certData []byte) *HTTPConfigurationBuilder
CACert specifies a CA certificate to be added to the trusted root CA list for HTTPS requests.
If the certificate is not valid, the LDClient constructor will return an error when you try to create the client.
func (*HTTPConfigurationBuilder) CACertFile ¶
func (b *HTTPConfigurationBuilder) CACertFile(filePath string) *HTTPConfigurationBuilder
CACertFile specifies a CA certificate to be added to the trusted root CA list for HTTPS requests, reading the certificate data from a file in PEM format.
If the certificate is not valid or the file does not exist, the LDClient constructor will return an error when you try to create the client.
func (*HTTPConfigurationBuilder) ConnectTimeout ¶
func (b *HTTPConfigurationBuilder) ConnectTimeout(connectTimeout time.Duration) *HTTPConfigurationBuilder
ConnectTimeout sets the connection timeout.
This is the maximum amount of time to wait for each individual connection attempt to a remote service before determining that that attempt has failed. It is not the same as the timeout for initializing the SDK client (the waitFor parameter to MakeClient); that is the total length of time that MakeClient will wait regardless of how many connection attempts are required.
config := ld.Config{ HTTP: ldcomponents.ConnectTimeout(), }
func (*HTTPConfigurationBuilder) CreateHTTPConfiguration ¶
func (b *HTTPConfigurationBuilder) CreateHTTPConfiguration( basicConfiguration interfaces.BasicConfiguration, ) (interfaces.HTTPConfiguration, error)
CreateHTTPConfiguration is called internally by the SDK.
func (*HTTPConfigurationBuilder) DescribeConfiguration ¶
func (b *HTTPConfigurationBuilder) DescribeConfiguration() ldvalue.Value
DescribeConfiguration is internally by the SDK to inspect the configuration.
func (*HTTPConfigurationBuilder) HTTPClientFactory ¶
func (b *HTTPConfigurationBuilder) HTTPClientFactory(httpClientFactory func() *http.Client) *HTTPConfigurationBuilder
HTTPClientFactory specifies a function for creating each HTTP client instance that is used by the SDK.
If you use this option, it overrides any other settings that you may have specified with ConnectTimeout or ProxyURL; you are responsible for setting up any desired custom configuration on the HTTP client. The SDK may modify the client properties after the client is created (for instance, to add caching), but will not replace the underlying Transport, and will not modify any timeout properties you set.
func (*HTTPConfigurationBuilder) ProxyURL ¶
func (b *HTTPConfigurationBuilder) ProxyURL(proxyURL string) *HTTPConfigurationBuilder
ProxyURL specifies a proxy URL to be used for all requests. This overrides any setting of the HTTP_PROXY, HTTPS_PROXY, or NO_PROXY environment variables.
If the string is not a valid URL, the LDClient constructor will return an error when you try to create the client.
func (*HTTPConfigurationBuilder) UserAgent ¶
func (b *HTTPConfigurationBuilder) UserAgent(userAgent string) *HTTPConfigurationBuilder
UserAgent specifies an additional User-Agent header value to send with HTTP requests.
func (*HTTPConfigurationBuilder) Wrapper ¶
func (b *HTTPConfigurationBuilder) Wrapper(wrapperName, wrapperVersion string) *HTTPConfigurationBuilder
Wrapper allows wrapper libraries to set an identifying name for the wrapper being used.
This will be sent in request headers during requests to the LaunchDarkly servers to allow recording metrics on the usage of these wrapper libraries.
type LoggingConfigurationBuilder ¶
type LoggingConfigurationBuilder struct {
// contains filtered or unexported fields
}
LoggingConfigurationBuilder contains methods for configuring the SDK's logging behavior.
If you want to set non-default values for any of these properties, create a builder with ldcomponents.Logging(), change its properties with the LoggingConfigurationBuilder methods, and store it in Config.Logging:
config := ld.Config{ Logging: ldcomponents.Logging().MinLevel(ldlog.Warn), }
func Logging ¶
func Logging() *LoggingConfigurationBuilder
Logging returns a configuration builder for the SDK's logging configuration.
The default configuration has logging enabled with default settings. If you want to set non-default values for any of these properties, create a builder with ldcomponents.Logging(), change its properties with the LoggingConfigurationBuilder methods, and store it in Config.Logging:
config := ld.Config{ Logging: ldcomponents.Logging().MinLevel(ldlog.Warn), }
func (*LoggingConfigurationBuilder) CreateLoggingConfiguration ¶
func (b *LoggingConfigurationBuilder) CreateLoggingConfiguration( basic interfaces.BasicConfiguration, ) (interfaces.LoggingConfiguration, error)
CreateLoggingConfiguration is called internally by the SDK.
func (*LoggingConfigurationBuilder) LogDataSourceOutageAsErrorAfter ¶
func (b *LoggingConfigurationBuilder) LogDataSourceOutageAsErrorAfter( logDataSourceOutageAsErrorAfter time.Duration, ) *LoggingConfigurationBuilder
LogDataSourceOutageAsErrorAfter sets the time threshold, if any, after which the SDK will log a data source outage at Error level instead of Warn level.
A data source outage means that an error condition, such as a network interruption or an error from the LaunchDarkly service, is preventing the SDK from receiving feature flag updates. Many outages are brief and the SDK can recover from them quickly; in that case it may be undesirable to log an Error line, which might trigger an unwanted automated alert depending on your monitoring tools. So, by default, the SDK logs such errors at Warn level. However, if the amount of time specified by this method elapses before the data source starts working again, the SDK will log an additional message at Error level to indicate that this is a sustained problem.
The default is DefaultLogDataSourceOutageAsErrorAfter (one minute). Setting it to zero will disable this feature, so you will only get Warn messages.
func (*LoggingConfigurationBuilder) LogEvaluationErrors ¶
func (b *LoggingConfigurationBuilder) LogEvaluationErrors(logEvaluationErrors bool) *LoggingConfigurationBuilder
LogEvaluationErrors sets whether the client should log a warning message whenever a flag cannot be evaluated due to an error (e.g. there is no flag with that key, or the user properties are invalid). By default, these messages are not logged, although you can detect such errors programmatically using the VariationDetail methods.
func (*LoggingConfigurationBuilder) LogUserKeyInErrors ¶
func (b *LoggingConfigurationBuilder) LogUserKeyInErrors(logUserKeyInErrors bool) *LoggingConfigurationBuilder
LogUserKeyInErrors sets whether log messages for errors related to a specific user can include the user key. By default, they will not, since the user key might be considered privileged information.
func (*LoggingConfigurationBuilder) Loggers ¶
func (b *LoggingConfigurationBuilder) Loggers(loggers ldlog.Loggers) *LoggingConfigurationBuilder
Loggers specifies an instance of ldlog.Loggers to use for SDK logging. The ldlog package contains methods for customizing the destination and level filtering of log output.
func (*LoggingConfigurationBuilder) MinLevel ¶
func (b *LoggingConfigurationBuilder) MinLevel(level ldlog.LogLevel) *LoggingConfigurationBuilder
MinLevel specifies the minimum level for log output, where ldlog.Debug is the lowest and ldlog.Error is the highest. Log messages at a level lower than this will be suppressed. The default is ldlog.Info.
This is equivalent to creating an ldlog.Loggers instance, calling SetMinLevel() on it, and then passing it to LoggingConfigurationBuilder.Loggers().
type PersistentDataStoreBuilder ¶
type PersistentDataStoreBuilder struct {
// contains filtered or unexported fields
}
PersistentDataStoreBuilder is a configurable factory for a persistent data store.
Several database integrations exist for the LaunchDarkly SDK, each with its own behavior and options specific to that database; this is described via some implementation of PersistentDataStoreFactory. There is also universal behavior that the SDK provides for all persistent data stores, such as caching; the PersistentDataStoreBuilder adds this.
After configuring this object, store it in the DataSource field of your SDK configuration. For example, using the Redis integration:
config := ld.Config{ DataStore: ldcomponents.PersistentDataStore( ldredis.DataStore().URL("redis://my-redis-host"), ).CacheSeconds(15), }
In this example, URL() is an option specifically for the Redis integration, whereas CacheSeconds() is an option that can be used for any persistent data store.
func PersistentDataStore ¶
func PersistentDataStore(persistentDataStoreFactory interfaces.PersistentDataStoreFactory) *PersistentDataStoreBuilder
PersistentDataStore returns a configuration builder for some implementation of a persistent data store.
This method is used in conjunction with another factory object provided by specific components such as the Redis integration. The latter provides builder methods for options that are specific to that integration, while the PersistentDataStoreBuilder provides options that are applicable to any persistent data store (such as caching). For example:
config := ld.Config{ DataStore: ldcomponents.PersistentDataStore( ldredis.DataStore().URL("redis://my-redis-host"), ).CacheSeconds(15), }
See PersistentDataStoreBuilder for more on how this method is used.
For more information on the available persistent data store implementations, see the reference guide on "Using a persistent feature store": https://docs.launchdarkly.com/sdk/concepts/feature-store
func (*PersistentDataStoreBuilder) CacheForever ¶
func (b *PersistentDataStoreBuilder) CacheForever() *PersistentDataStoreBuilder
CacheForever specifies that the in-memory cache should never expire. In this mode, data will be written to both the underlying persistent store and the cache, but will only ever be read from the persistent store if the SDK is restarted.
Use this mode with caution: it means that in a scenario where multiple processes are sharing the database, and the current process loses connectivity to LaunchDarkly while other processes are still receiving updates and writing them to the database, the current process will have stale data.
func (*PersistentDataStoreBuilder) CacheSeconds ¶
func (b *PersistentDataStoreBuilder) CacheSeconds(cacheSeconds int) *PersistentDataStoreBuilder
CacheSeconds is a shortcut for calling CacheTime with a duration in seconds.
func (*PersistentDataStoreBuilder) CacheTime ¶
func (b *PersistentDataStoreBuilder) CacheTime(cacheTime time.Duration) *PersistentDataStoreBuilder
CacheTime specifies the cache TTL. Items will be evicted from the cache after this amount of time from the time when they were originally cached.
If the value is zero, caching is disabled (equivalent to NoCaching).
If the value is negative, data is cached forever (equivalent to CacheForever).
func (*PersistentDataStoreBuilder) CreateDataStore ¶
func (b *PersistentDataStoreBuilder) CreateDataStore( context interfaces.ClientContext, dataStoreUpdates interfaces.DataStoreUpdates, ) (interfaces.DataStore, error)
CreateDataStore is called by the SDK to create the data store implemntation object.
func (*PersistentDataStoreBuilder) DescribeConfiguration ¶
func (b *PersistentDataStoreBuilder) DescribeConfiguration() ldvalue.Value
DescribeConfiguration is used internally by the SDK to inspect the configuration.
func (*PersistentDataStoreBuilder) NoCaching ¶
func (b *PersistentDataStoreBuilder) NoCaching() *PersistentDataStoreBuilder
NoCaching specifies that the SDK should not use an in-memory cache for the persistent data store. This means that every feature flag evaluation will trigger a data store query.
type PollingDataSourceBuilder ¶
type PollingDataSourceBuilder struct {
// contains filtered or unexported fields
}
PollingDataSourceBuilder provides methods for configuring the polling data source.
See PollingDataSource for usage.
func PollingDataSource ¶
func PollingDataSource() *PollingDataSourceBuilder
PollingDataSource returns a configurable factory for using polling mode to get feature flag data.
Polling is not the default behavior; by default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly. In polling mode, the SDK instead makes a new HTTP request to LaunchDarkly at regular intervals. HTTP caching allows it to avoid redundantly downloading data if there have been no changes, but polling is still less efficient than streaming and should only be used on the advice of LaunchDarkly support.
To use polling mode, create a builder with PollingDataSource(), set its properties with the methods of PollingDataSourceBuilder, and then store it in the DataSource field of your SDK configuration:
config := ld.Config{ DataSource: ldcomponents.PollingDataSource().PollInterval(45 * time.Second), }
func (*PollingDataSourceBuilder) BaseURI ¶
func (b *PollingDataSourceBuilder) BaseURI(baseURI string) *PollingDataSourceBuilder
BaseURI sets a custom base URI for the polling service.
You will only need to change this value in the following cases:
1. You are using the Relay Proxy (https://docs.launchdarkly.com/docs/the-relay-proxy). Set BaseURI to the base URI of the Relay Proxy instance.
2. You are connecting to a test server or anything else other than the standard LaunchDarkly service.
func (*PollingDataSourceBuilder) CreateDataSource ¶
func (b *PollingDataSourceBuilder) CreateDataSource( context interfaces.ClientContext, dataSourceUpdates interfaces.DataSourceUpdates, ) (interfaces.DataSource, error)
CreateDataSource is called by the SDK to create the data source instance.
func (*PollingDataSourceBuilder) DescribeConfiguration ¶
func (b *PollingDataSourceBuilder) DescribeConfiguration() ldvalue.Value
DescribeConfiguration is used internally by the SDK to inspect the configuration.
func (*PollingDataSourceBuilder) PollInterval ¶
func (b *PollingDataSourceBuilder) PollInterval(pollInterval time.Duration) *PollingDataSourceBuilder
PollInterval sets the interval at which the SDK will poll for feature flag updates.
The default and minimum value is DefaultPollInterval. Values less than this will be set to the default.
type StreamingDataSourceBuilder ¶
type StreamingDataSourceBuilder struct {
// contains filtered or unexported fields
}
StreamingDataSourceBuilder provides methods for configuring the streaming data source.
See StreamingDataSource for usage.
func StreamingDataSource ¶
func StreamingDataSource() *StreamingDataSourceBuilder
StreamingDataSource returns a configurable factory for using streaming mode to get feature flag data.
By default, the SDK uses a streaming connection to receive feature flag data from LaunchDarkly. To use the default behavior, you do not need to call this method. However, if you want to customize the behavior of the connection, call this method to obtain a builder, set its properties with the StreamingDataSourceBuilder methods, and then store it in the DataSource field of your SDK configuration:
config := ld.Config{ DataSource: ldcomponents.StreamingDataSource().InitialReconnectDelay(500 * time.Millisecond), }
func (*StreamingDataSourceBuilder) BaseURI ¶
func (b *StreamingDataSourceBuilder) BaseURI(baseURI string) *StreamingDataSourceBuilder
BaseURI sets a custom base URI for the streaming service.
You will only need to change this value in the following cases:
1. You are using the Relay Proxy (https://docs.launchdarkly.com/docs/the-relay-proxy). Set BaseURI to the base URI of the Relay Proxy instance.
2. You are connecting to a test server or anything else other than the standard LaunchDarkly service.
func (*StreamingDataSourceBuilder) CreateDataSource ¶
func (b *StreamingDataSourceBuilder) CreateDataSource( context interfaces.ClientContext, dataSourceUpdates interfaces.DataSourceUpdates, ) (interfaces.DataSource, error)
CreateDataSource is called by the SDK to create the data source instance.
func (*StreamingDataSourceBuilder) DescribeConfiguration ¶
func (b *StreamingDataSourceBuilder) DescribeConfiguration() ldvalue.Value
DescribeConfiguration is used internally by the SDK to inspect the configuration.
func (*StreamingDataSourceBuilder) InitialReconnectDelay ¶
func (b *StreamingDataSourceBuilder) InitialReconnectDelay( initialReconnectDelay time.Duration, ) *StreamingDataSourceBuilder
InitialReconnectDelay sets the initial reconnect delay for the streaming connection.
The streaming service uses a backoff algorithm (with jitter) every time the connection needs to be reestablished. The delay for the first reconnection will start near this value, and then increase exponentially for any subsequent connection failures.
The default value is DefaultInitialReconnectDelay.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ldstoreimpl contains SDK data store implementation objects that may be used by external code such as custom data store integrations and internal LaunchDarkly components.
|
Package ldstoreimpl contains SDK data store implementation objects that may be used by external code such as custom data store integrations and internal LaunchDarkly components. |