C++ Server-Side SDK
LaunchDarkly SDK
Public Types | Public Member Functions | List of all members
launchdarkly::server_side::IClient Class Referenceabstract

#include <client.hpp>

Inheritance diagram for launchdarkly::server_side::IClient:
Inheritance graph
[legend]

Public Types

using FlagKey = std::string
 

Public Member Functions

virtual std::future< bool > StartAsync ()=0
 
virtual bool Initialized () const =0
 
virtual class AllFlagsState AllFlagsState (Context const &context, AllFlagsState::Options options=AllFlagsState::Options::Default)=0
 
virtual void Track (Context const &ctx, std::string event_name, Value data, double metric_value)=0
 
virtual void Track (Context const &ctx, std::string event_name, Value data)=0
 
virtual void Track (Context const &ctx, std::string event_name)=0
 
virtual void FlushAsync ()=0
 
virtual void Identify (Context context)=0
 
virtual bool BoolVariation (Context const &ctx, FlagKey const &key, bool default_value)=0
 
virtual EvaluationDetail< bool > BoolVariationDetail (Context const &ctx, FlagKey const &key, bool default_value)=0
 
virtual std::string StringVariation (Context const &ctx, FlagKey const &key, std::string default_value)=0
 
virtual EvaluationDetail< std::string > StringVariationDetail (Context const &ctx, FlagKey const &key, std::string default_value)=0
 
virtual double DoubleVariation (Context const &ctx, FlagKey const &key, double default_value)=0
 
virtual EvaluationDetail< double > DoubleVariationDetail (Context const &ctx, FlagKey const &key, double default_value)=0
 
virtual int IntVariation (Context const &ctx, FlagKey const &key, int default_value)=0
 
virtual EvaluationDetail< int > IntVariationDetail (Context const &ctx, FlagKey const &key, int default_value)=0
 
virtual Value JsonVariation (Context const &ctx, FlagKey const &key, Value default_value)=0
 
virtual EvaluationDetail< ValueJsonVariationDetail (Context const &ctx, FlagKey const &key, Value default_value)=0
 
virtual IDataSourceStatusProviderDataSourceStatus ()=0
 
 IClient (IClient const &item)=delete
 
 IClient (IClient &&item)=delete
 
IClientoperator= (IClient const &)=delete
 
IClientoperator= (IClient &&)=delete
 

Detailed Description

Interface for the standard SDK client methods and properties.

Member Typedef Documentation

◆ FlagKey

Represents the key of a feature flag.

Member Function Documentation

◆ AllFlagsState()

virtual class AllFlagsState launchdarkly::server_side::IClient::AllFlagsState ( Context const &  context,
AllFlagsState::Options  options = AllFlagsState::Options::Default 
)
pure virtual

Evaluates all flags for a context, returning a data structure containing the results and additional flag metadata.

The method's behavior can be controlled by passing a combination of one or more options.

A common use-case for AllFlagsState is to generate data suitable for bootstrapping the client-side JavaScript SDK.

This method will not send analytics events back to LaunchDarkly.

Parameters
contextThe context against which all flags will be evaluated.
optionsA combination of one or more options. Omitting this argument is equivalent to passing AllFlagsState::Options::Default.
Returns
An AllFlagsState data structure.

Implemented in launchdarkly::server_side::Client, and launchdarkly::server_side::ClientImpl.

◆ BoolVariation()

virtual bool launchdarkly::server_side::IClient::BoolVariation ( Context const &  ctx,
FlagKey const &  key,
bool  default_value 
)
pure virtual

Returns the boolean value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ BoolVariationDetail()

virtual EvaluationDetail<bool> launchdarkly::server_side::IClient::BoolVariationDetail ( Context const &  ctx,
FlagKey const &  key,
bool  default_value 
)
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.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ DataSourceStatus()

virtual IDataSourceStatusProvider& launchdarkly::server_side::IClient::DataSourceStatus ( )
pure virtual

Returns an interface which provides methods for subscribing to data source status.

Returns
A data source status provider.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ DoubleVariation()

virtual double launchdarkly::server_side::IClient::DoubleVariation ( Context const &  ctx,
FlagKey const &  key,
double  default_value 
)
pure virtual

Returns the double value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ DoubleVariationDetail()

virtual EvaluationDetail<double> launchdarkly::server_side::IClient::DoubleVariationDetail ( Context const &  ctx,
FlagKey const &  key,
double  default_value 
)
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.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ FlushAsync()

virtual void launchdarkly::server_side::IClient::FlushAsync ( )
pure virtual

Tells the client that all pending analytics events (if any) should be delivered as soon as possible.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ Identify()

virtual void launchdarkly::server_side::IClient::Identify ( Context  context)
pure virtual

Generates an identify event for a context.

Parameters
contextThe new evaluation context.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ Initialized()

virtual bool launchdarkly::server_side::IClient::Initialized ( ) const
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.

Returns
True if the client is initialized.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ IntVariation()

virtual int launchdarkly::server_side::IClient::IntVariation ( Context const &  ctx,
FlagKey const &  key,
int  default_value 
)
pure virtual

Returns the int value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ IntVariationDetail()

virtual EvaluationDetail<int> launchdarkly::server_side::IClient::IntVariationDetail ( Context const &  ctx,
FlagKey const &  key,
int  default_value 
)
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.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ JsonVariation()

virtual Value launchdarkly::server_side::IClient::JsonVariation ( Context const &  ctx,
FlagKey const &  key,
Value  default_value 
)
pure virtual

Returns the JSON value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ JsonVariationDetail()

virtual EvaluationDetail<Value> launchdarkly::server_side::IClient::JsonVariationDetail ( Context const &  ctx,
FlagKey const &  key,
Value  default_value 
)
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.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ StartAsync()

virtual std::future<bool> launchdarkly::server_side::IClient::StartAsync ( )
pure virtual

Connects the client to LaunchDarkly's flag delivery endpoints.

StartAsync must be called once for the SDK to start receiving flag data. It does not need to be called more than one time.

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::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ StringVariation()

virtual std::string launchdarkly::server_side::IClient::StringVariation ( Context const &  ctx,
FlagKey const &  key,
std::string  default_value 
)
pure virtual

Returns the string value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ StringVariationDetail()

virtual EvaluationDetail<std::string> launchdarkly::server_side::IClient::StringVariationDetail ( Context const &  ctx,
FlagKey const &  key,
std::string  default_value 
)
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.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ Track() [1/3]

virtual void launchdarkly::server_side::IClient::Track ( Context const &  ctx,
std::string  event_name 
)
pure virtual

Tracks that the current context performed an event for the given event name.

Parameters
event_nameThe name of the event.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ Track() [2/3]

virtual void launchdarkly::server_side::IClient::Track ( Context const &  ctx,
std::string  event_name,
Value  data 
)
pure virtual

Tracks that the current context performed an event for the given event name, with additional JSON data.

Parameters
event_nameThe name of the event.
dataA JSON value containing additional data associated with the event.

Implemented in launchdarkly::server_side::ClientImpl, and launchdarkly::server_side::Client.

◆ Track() [3/3]

virtual void launchdarkly::server_side::IClient::Track ( Context const &  ctx,
std::string  event_name,
Value  data,
double  metric_value 
)
pure virtual

Tracks that the current context performed an event for the given event name, and associates it with a numeric metric value.

Parameters
event_nameThe name of the event.
dataA JSON value containing additional data associated with the event.
metric_valuethis 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::server_side::ClientImpl, and launchdarkly::server_side::Client.


The documentation for this class was generated from the following file: