C++ Client-Side SDK
LaunchDarkly SDK
|
#include <client.hpp>
Public Types | |
using | FlagKey = std::string |
Public Member Functions | |
virtual std::future< bool > | StartAsync ()=0 |
virtual bool | Initialized () const =0 |
virtual std::unordered_map< FlagKey, Value > | AllFlags () const =0 |
virtual void | Track (std::string event_name, Value data, double metric_value)=0 |
virtual void | Track (std::string event_name, Value data)=0 |
virtual void | Track (std::string event_name)=0 |
virtual void | FlushAsync ()=0 |
virtual std::future< bool > | IdentifyAsync (Context context)=0 |
virtual bool | BoolVariation (FlagKey const &key, bool default_value)=0 |
virtual EvaluationDetail< bool > | BoolVariationDetail (FlagKey const &key, bool default_value)=0 |
virtual std::string | StringVariation (FlagKey const &key, std::string default_value)=0 |
virtual EvaluationDetail< std::string > | StringVariationDetail (FlagKey const &key, std::string default_value)=0 |
virtual double | DoubleVariation (FlagKey const &key, double default_value)=0 |
virtual EvaluationDetail< double > | DoubleVariationDetail (FlagKey const &key, double default_value)=0 |
virtual int | IntVariation (FlagKey const &key, int default_value)=0 |
virtual EvaluationDetail< int > | IntVariationDetail (FlagKey const &key, int default_value)=0 |
virtual Value | JsonVariation (FlagKey const &key, Value default_value)=0 |
virtual EvaluationDetail< Value > | JsonVariationDetail (FlagKey const &key, Value default_value)=0 |
virtual data_sources::IDataSourceStatusProvider & | DataSourceStatus ()=0 |
virtual flag_manager::IFlagNotifier & | FlagNotifier ()=0 |
IClient (IClient const &item)=delete | |
IClient (IClient &&item)=delete | |
IClient & | operator= (IClient const &)=delete |
IClient & | operator= (IClient &&)=delete |
Interface for the standard SDK client methods and properties.
After an SDK instance is created it should be started with the StartAsync method. Subsequently if a change of context is required the IdentifyAsync method should be used.
using launchdarkly::client_side::IClient::FlagKey = std::string |
Represents the key of a feature flag.
|
pure virtual |
Returns a map from feature flag keys to feature flag values for the current context.
This method will not send analytics events back to LaunchDarkly.
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the boolean value of a feature flag for a given flag key.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the boolean value of a feature flag for a given flag key, in an object that also describes the way the value was determined.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns an interface which provides methods for subscribing to data source status.
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the double value of a feature flag for a given flag key.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the double value of a feature flag for a given flag key, in an object that also describes the way the value was determined.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns an interface which provides methods for subscribing to data flag changes.
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Tells the client that all pending analytics events (if any) should be delivered as soon as possible.
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Changes the current evaluation context, requests flags for that context from LaunchDarkly if online, and generates an analytics event to tell LaunchDarkly about the context.
Only one IdentifyAsync can be in progress at once; calling it concurrently invokes undefined behavior.
To block until the identify operation is complete, call wait() on the returned future.
The returned future will resolve to true or false based on the logic outlined on Initialized.
context | The new evaluation context. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns a boolean value indicating LaunchDarkly connection and flag state within the client.
When you first start the client, once StartAsync has completed, Initialized should return true if and only if either 1. it connected to LaunchDarkly and successfully retrieved flags, or 2. it started in offline mode so there's no need to connect to LaunchDarkly.
If the client timed out trying to connect to LD, then Initialized returns false (even if we do have cached flags).
If the client connected and got a 401 error, Initialized will return false.
This serves the purpose of letting the app know that there was a problem of some kind.
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the int value of a feature flag for a given flag key.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the int value of a feature flag for a given flag key, in an object that also describes the way the value was determined.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the JSON value of a feature flag for a given flag key.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the JSON value of a feature flag for a given flag key, in an object that also describes the way the value was determined.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Connects the client to LaunchDarkly's flag delivery endpoints.
StartAsync must be called once for the SDK to start receiving flag data. StartAsync only needs to be called one time for the lifetime of the SDK client. To change the context associated with evaluations please call the IdentifyAsync method.
The returned future will resolve to true or false based on the logic outlined on Initialized.
Blocking indefinitely on the future (e.g. by calling .get() or .wait()) is highly discouraged. Instead, use a method that takes a timeout like .wait_for() or .wait_until(), or do not wait.
Otherwise, the application may hang indefinitely if the client cannot connect to LaunchDarkly.
While the client is connecting asynchronously, it is safe to call variation methods, which will return application-defined default values.
The client will always continue to attempt to connect asynchronously after being started unless it encounters an unrecoverable error. The returned promise timing out does not affect this behavior.
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the string value of a feature flag for a given flag key.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Returns the string value of a feature flag for a given flag key, in an object that also describes the way the value was determined.
key | The unique feature key for the feature flag. |
default_value | The default value of the flag. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Tracks that the current context performed an event for the given event name.
event_name | The name of the event. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Tracks that the current context performed an event for the given event name, with additional JSON data.
event_name | The name of the event. |
data | A JSON value containing additional data associated with the event. |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.
|
pure virtual |
Tracks that the current context performed an event for the given event name, and associates it with a numeric metric value.
event_name | The name of the event. |
data | A JSON value containing additional data associated with the event. |
metric_value | this value is used by the LaunchDarkly experimentation feature in numeric custom metrics, and will also be returned as part of the custom event for Data Export |
Implemented in launchdarkly::client_side::ClientImpl, and launchdarkly::client_side::Client.