Documentation ¶
Index ¶
- func Configure(opts ...ConfigOption) error
- type Client
- func (c *Client) Connect() error
- func (c *Client) QueryBool(ctx context.Context, key FlagName, fallbackValue bool) (bool, error)
- func (c *Client) QueryBoolWithEvaluationContext(key FlagName, evalContext evaluationcontext.Context, fallbackValue bool) (bool, error)
- func (c *Client) QueryInt(ctx context.Context, key FlagName, fallbackValue int) (int, error)
- func (c *Client) QueryIntWithEvaluationContext(key FlagName, evalContext evaluationcontext.Context, fallbackValue int) (int, error)
- func (c *Client) QueryString(ctx context.Context, key FlagName, fallbackValue string) (string, error)
- func (c *Client) QueryStringWithEvaluationContext(key FlagName, evalContext evaluationcontext.Context, fallbackValue string) (string, error)
- func (c *Client) RawClient() interface{}
- func (c *Client) Shutdown() error
- func (c *Client) TestDataSource() (*ldtestdata.TestDataSource, error)
- type ConfigOption
- type FlagName
- type LambdaModeConfig
- type ProxyModeConfig
- type TestModeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
func Configure(opts ...ConfigOption) error
Configure configures the client as a managed singleton.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around the LaunchDarkly client.
func GetDefaultClient ¶
GetDefaultClient returns the managed singleton client. An error is returned if the client is not yet configured.
func NewClient ¶
func NewClient(opts ...ConfigOption) (*Client, error)
NewClient configures and returns an instance of the client. The client is configured automatically from the LAUNCHDARKLY_CONFIGURATION environment variable if it exists. Otherwise, the client falls back to test mode. See launchdarkly/flags/doc.go for more information.
func (*Client) Connect ¶
Connect attempts to establish the initial connection to LaunchDarkly. An error is returned if a connection has already been established, or a connection error occurs.
func (*Client) QueryBool ¶
QueryBool retrieves the value of a boolean flag. User attributes are extracted from the context. The supplied fallback value is always reflected in the returned value regardless of whether an error occurs.
func (*Client) QueryBoolWithEvaluationContext ¶
func (c *Client) QueryBoolWithEvaluationContext(key FlagName, evalContext evaluationcontext.Context, fallbackValue bool) (bool, error)
QueryBoolWithEvaluationContext retrieves the value of a boolean flag. An evaluation context must be supplied manually. The supplied fallback value is always reflected in the returned value regardless of whether an error occurs.
func (*Client) QueryInt ¶
QueryInt retrieves the value of an integer flag. User attributes are extracted from the context. The supplied fallback value is always reflected in the returned value regardless of whether an error occurs.
func (*Client) QueryIntWithEvaluationContext ¶
func (c *Client) QueryIntWithEvaluationContext(key FlagName, evalContext evaluationcontext.Context, fallbackValue int) (int, error)
QueryIntWithEvaluationContext retrieves the value of an integer flag. An evaluation context must be supplied manually. The supplied fallback value is always reflected in the returned value regardless of whether an error occurs.
func (*Client) QueryString ¶
func (c *Client) QueryString(ctx context.Context, key FlagName, fallbackValue string) (string, error)
QueryString retrieves the value of a string flag. User attributes are extracted from the context. The supplied fallback value is always reflected in the returned value regardless of whether an error occurs.
func (*Client) QueryStringWithEvaluationContext ¶
func (c *Client) QueryStringWithEvaluationContext(key FlagName, evalContext evaluationcontext.Context, fallbackValue string) (string, error)
QueryStringWithEvaluationContext retrieves the value of a string flag. An evaluation context must be supplied manually. The supplied fallback value is always reflected in the returned value regardless of whether an error occurs.
func (*Client) RawClient ¶
func (c *Client) RawClient() interface{}
RawClient returns the wrapped LaunchDarkly client. The return value should be casted to an *ld.LDClient instance.
func (*Client) Shutdown ¶
Shutdown instructs the wrapped LaunchDarkly client to close any open connections and flush any flag evaluation events.
func (*Client) TestDataSource ¶
func (c *Client) TestDataSource() (*ldtestdata.TestDataSource, error)
TestDataSource returns the dynamic test data source used by the client, or an error if: - the client wasn't configured in test mode. - the client was configured to read test data from a JSON file.
See https://docs.launchdarkly.com/sdk/features/test-data-sources for more information on using the test data source returned by this method.
type ConfigOption ¶
type ConfigOption func(c *Client)
ConfigOption are functions that can be supplied to Configure and NewClient to configure the flags client.
func WithBigSegmentsDisabled ¶
func WithBigSegmentsDisabled() ConfigOption
func WithInitWait ¶
func WithInitWait(t time.Duration) ConfigOption
WithInitWait configures the client to wait for the given duration for the LaunchDarkly client to connect. If you don't provide this option, the client will wait up to 5 seconds by default.
func WithLambdaMode ¶
func WithLambdaMode(cfg *LambdaModeConfig) ConfigOption
WithLambdaMode configures the client to connect to Dynamo for flags.
func WithProxyMode ¶
func WithProxyMode(cfg *ProxyModeConfig) ConfigOption
WithProxyMode configures the client to connect to LaunchDarkly via the Relay Proxy. This is typically set automatically based on the LAUNCHDARKLY_CONFIGURATION environment variable. Only use this ConfigOption if you need to override the URL of the Relay Proxy to connect to.
func WithTestMode ¶
func WithTestMode(cfg *TestModeConfig) ConfigOption
WithTestMode configures the client in test mode. No connections are made to LaunchDarkly in this mode; all flag results are sourced from a local JSON file or at runtime through a dynamic test data source. See https://docs.launchdarkly.com/sdk/features/test-data-sources and https://docs.launchdarkly.com/sdk/features/flags-from-files for more information on test data sources.
type LambdaModeConfig ¶
LambdaModeConfig declares optional overrides for configuring the client in Lambda mode.
type ProxyModeConfig ¶
type ProxyModeConfig struct {
RelayProxyURL string
}
ProxyModeConfig declares optional overrides for configuring the client in Proxy mode.
type TestModeConfig ¶
type TestModeConfig struct { FlagFilename string // contains filtered or unexported fields }
TestModeConfig declares configuration for running the client in test mode. Provide an instance of this struct if you wish to use a local JSON file as the source of flag data.