Interface ILdClient
Interface defining the public methods of LdClient.
Namespace: LaunchDarkly.Sdk.Server.Interfaces
Assembly: LaunchDarkly.ServerSdk.dll
Syntax
public interface ILdClient
Properties
| Edit this page View SourceBigSegmentStoreStatusProvider
A mechanism for tracking the status of a Big Segment store.
Declaration
IBigSegmentStoreStatusProvider BigSegmentStoreStatusProvider { get; }
Property Value
Type | Description |
---|---|
IBigSegmentStoreStatusProvider |
Remarks
The returned object has methods for checking whether the Big Segment store is (as far as the SDK knows) currently operational and tracking changes in this status. See IBigSegmentStoreStatusProvider for more about this functionality.
DataSourceStatusProvider
A mechanism for tracking the status of the data source.
Declaration
IDataSourceStatusProvider DataSourceStatusProvider { get; }
Property Value
Type | Description |
---|---|
IDataSourceStatusProvider |
Remarks
The data source is the mechanism that the SDK uses to get feature flag configurations, such as a streaming connection (the default) or poll requests. The IDataSourceStatusProvider has methods for checking whether the data source is (as far as the SDK knows) currently operational, and tracking changes in this status. This property will never be null.
DataStoreStatusProvider
A mechanism for tracking the status of a persistent data store.
Declaration
IDataStoreStatusProvider DataStoreStatusProvider { get; }
Property Value
Type | Description |
---|---|
IDataStoreStatusProvider |
Remarks
The IDataStoreStatusProvider has methods for checking whether the data store is (as far as the SDK knows) currently operational and tracking changes in this status. These are only relevant for a persistent data store; if you are using an in-memory data store, then this property is a stub object that always reports the store as operational.
FlagTracker
A mechanism for tracking changes in feature flag configurations.
Declaration
IFlagTracker FlagTracker { get; }
Property Value
Type | Description |
---|---|
IFlagTracker |
Remarks
The IFlagTracker contains methods for requesting notifications about feature flag changes using an event listener model.
Initialized
Tests whether the client is ready to be used.
Declaration
bool Initialized { get; }
Property Value
Type | Description |
---|---|
bool | true if the client is ready, or false if it is still initializing |
Methods
| Edit this page View SourceAllFlagsState(Context, params FlagsStateOption[])
Returns an object that encapsulates the state of all feature flags for a given context, which can be passed to front-end code.
Declaration
FeatureFlagsState AllFlagsState(Context context, params FlagsStateOption[] options)
Parameters
Type | Name | Description |
---|---|---|
Context | context | the evaluation context |
FlagsStateOption[] | options | optional FlagsStateOption values affecting how the state is computed-- for instance, to filter the set of flags to only include the client-side-enabled ones |
Returns
Type | Description |
---|---|
FeatureFlagsState | a FeatureFlagsState object (will never be null; see Valid |
Remarks
The object returned by this method contains the flag values as well as other metadata that is used by the LaunchDarkly JavaScript client, so it can be used for bootstrapping.
This method will not send analytics events back to LaunchDarkly.
BoolVariation(string, Context, bool)
Calculates the boolean value of a feature flag for a given context.
Declaration
bool BoolVariation(string key, Context context, bool defaultValue = false)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
bool | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
bool | the variation for the given context, or |
Remarks
If the flag variation does not have a boolean value, defaultValue
is returned.
If an error makes it impossible to evaluate the flag (for instance, the feature flag key
does not match any existing flag), defaultValue
is returned.
See Also
| Edit this page View SourceBoolVariationDetail(string, Context, bool)
Calculates the boolean value of a feature flag for a given context, and returns an object that describes the way the value was determined.
Declaration
EvaluationDetail<bool> BoolVariationDetail(string key, Context context, bool defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
bool | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
EvaluationDetail<bool> | an EvaluationDetail<T> object |
Remarks
The Reason property in the result will also be included in analytics events, if you are capturing detailed event data for this flag.
The behavior is otherwise identical to BoolVariation(string, Context, bool).
See Also
| Edit this page View SourceDoubleVariation(string, Context, double)
Calculates the double-precision floating-point numeric value of a feature flag for a given context.
Declaration
double DoubleVariation(string key, Context context, double defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
double | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
double | the variation for the given context, or |
Remarks
If the flag variation does not have a numeric value, defaultValue
is returned.
If an error makes it impossible to evaluate the flag (for instance, the feature flag key
does not match any existing flag), defaultValue
is returned.
See Also
| Edit this page View SourceDoubleVariationDetail(string, Context, double)
Calculates the double-precision floating-point numeric value of a feature flag for a given context, and returns an object that describes the way the value was determined.
Declaration
EvaluationDetail<double> DoubleVariationDetail(string key, Context context, double defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
double | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
EvaluationDetail<double> | an EvaluationDetail<T> object |
Remarks
The Reason property in the result will also be included in analytics events, if you are capturing detailed event data for this flag.
The behavior is otherwise identical to DoubleVariation(string, Context, double).
See Also
| Edit this page View SourceFloatVariation(string, Context, float)
Calculates the single-precision floating-point numeric value of a feature flag for a given context.
Declaration
float FloatVariation(string key, Context context, float defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
float | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
float | the variation for the given context, or |
Remarks
If the flag variation does not have a numeric value, defaultValue
is returned.
If an error makes it impossible to evaluate the flag (for instance, the feature flag key
does not match any existing flag), defaultValue
is returned.
See Also
| Edit this page View SourceFloatVariationDetail(string, Context, float)
Calculates the single-precision floating-point numeric value of a feature flag for a given context, and returns an object that describes the way the value was determined.
Declaration
EvaluationDetail<float> FloatVariationDetail(string key, Context context, float defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
float | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
EvaluationDetail<float> | an EvaluationDetail<T> object |
Remarks
The Reason property in the result will also be included in analytics events, if you are capturing detailed event data for this flag.
The behavior is otherwise identical to FloatVariation(string, Context, float).
See Also
| Edit this page View SourceFlush()
Tells the client that all pending analytics events (if any) should be delivered as soon as possible.
Declaration
void Flush()
Remarks
This flush is asynchronous, so this method will return before it is complete. To wait for the flush to complete, use FlushAndWait(TimeSpan) instead (or, if you are done with the SDK, Dispose()).
For more information, see: Flushing Events.
See Also
| Edit this page View SourceFlushAndWait(TimeSpan)
Tells the client to deliver any pending analytics events synchronously now.
Declaration
bool FlushAndWait(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | the maximum time to wait |
Returns
Type | Description |
---|---|
bool | true if completed, false if timed out |
Remarks
Unlike Flush(), this method waits for event delivery to finish. The timeout parameter, if greater than zero, specifies the maximum amount of time to wait. If the timeout elapses before delivery is finished, the method returns early and returns false; in this case, the SDK may still continue trying to deliver the events in the background.
If the timeout parameter is zero or negative, the method waits as long as necessary to deliver the events. However, the SDK does not retry event delivery indefinitely; currently, any network error or server error will cause the SDK to wait one second and retry one time, after which the events will be discarded so that the SDK will not keep consuming more memory for events indefinitely.
The method returns true if event delivery either succeeded, or definitively failed, before the timeout elapsed. It returns false if the timeout elapsed.
This method is also implicitly called if you call Dispose(). The difference is that FlushAndWait does not shut down the SDK client.
For more information, see: Flushing Events.
See Also
| Edit this page View SourceGetLogger()
Returns the logger instance used by this SDK instance.
Declaration
Logger GetLogger()
Returns
Type | Description |
---|---|
Logger | the logger instance used by the SDK |
Remarks
This allows for access to the logger by other LaunchDarkly components, such as the Migration class.
It also allows for usage of the logger in wrapper implementations.
It is not intended for general purpose application logging.
Identify(Context)
Reports details about an evaluation context.
Declaration
void Identify(Context context)
Parameters
Type | Name | Description |
---|---|---|
Context | context | the evaluation context |
Remarks
This method simply creates an analytics event containing the context attributes, to that LaunchDarkly will know about that context if it does not already.
Calling any evaluation method, such as BoolVariation(string, Context, bool), also sends the context information to LaunchDarkly (if events are enabled), so you only need to use Identify(Context) if you want to identify the context without evaluating a flag.
Note that event delivery is asynchronous, so the event may not actually be sent until later; see Flush().
For more information, see the Reference Guide.
IntVariation(string, Context, int)
Calculates the integer value of a feature flag for a given context.
Declaration
int IntVariation(string key, Context context, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
int | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
int | the variation for the given context, or |
Remarks
If the flag variation has a numeric value that is not an integer, it is rounded to the nearest integer. This rounding behavior may be changed in a future version of the SDK (for instance, to round toward zero like the usual float-to-int conversion in C#), so you should avoid relying on it.
If the flag variation does not have a numeric value, defaultValue
is returned.
If an error makes it impossible to evaluate the flag (for instance, the feature flag key
does not match any existing flag), defaultValue
is returned.
See Also
| Edit this page View SourceIntVariationDetail(string, Context, int)
Calculates the integer value of a feature flag for a given context, and returns an object that describes the way the value was determined.
Declaration
EvaluationDetail<int> IntVariationDetail(string key, Context context, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
int | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
EvaluationDetail<int> | an EvaluationDetail<T> object |
Remarks
The Reason property in the result will also be included in analytics events, if you are capturing detailed event data for this flag.
The behavior is otherwise identical to IntVariation(string, Context, int).
See Also
| Edit this page View SourceIsOffline()
Returns true if the client has been configured to be offline.
Declaration
bool IsOffline()
Returns
Type | Description |
---|---|
bool | true if the client is configured to be offline |
Remarks
This value will be static for the execution of a client. If you want active data source status for an online client, then use DataSourceStatusProvider.
JsonVariation(string, Context, LdValue)
Calculates the value of a feature flag for a given context as any JSON value type.
Declaration
LdValue JsonVariation(string key, Context context, LdValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
LdValue | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
LdValue | the variation for the given context, or |
Remarks
The type LdValue is used to represent any of the value types that can exist in JSON. Use LdValue methods to examine its type and value.
If an error makes it impossible to evaluate the flag (for instance, the feature flag key
does not match any existing flag), defaultValue
is returned.
See Also
| Edit this page View SourceJsonVariationDetail(string, Context, LdValue)
Calculates the value of a feature flag for a given context as any JSON value type, and returns an object that describes the way the value was determined.
Declaration
EvaluationDetail<LdValue> JsonVariationDetail(string key, Context context, LdValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
LdValue | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
EvaluationDetail<LdValue> | an EvaluationDetail<T> object |
Remarks
The Reason property in the result will also be included in analytics events, if you are capturing detailed event data for this flag.
The behavior is otherwise identical to JsonVariationDetail(string, Context, LdValue).
See Also
| Edit this page View SourceMigrationVariation(string, Context, MigrationStage)
Returns the migration stage of the migration feature flag for the given evaluation context.
Declaration
MigrationVariation MigrationVariation(string key, Context context, MigrationStage defaultStage)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
MigrationStage | defaultStage | the default value of the flag |
Returns
Type | Description |
---|---|
MigrationVariation | an MigrationVariation(string, Context, MigrationStage) object |
SecureModeHash(Context)
Creates a hash string that can be used by the JavaScript SDK to identify a context.
Declaration
string SecureModeHash(Context context)
Parameters
Type | Name | Description |
---|---|---|
Context | context | the evaluation context |
Returns
Type | Description |
---|---|
string | the hash, or null if the hash could not be calculated |
Remarks
See Secure mode in the JavaScript SDK Reference.
StringVariation(string, Context, string)
Calculates the string value of a feature flag for a given context.
Declaration
string StringVariation(string key, Context context, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
string | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
string | the variation for the given context, or |
Remarks
If the flag variation does not have a string value, defaultValue
is returned.
Normally, the string value of a flag should not be null, since the LaunchDarkly UI
does not allow you to assign a null value to a flag variation. However, since it may be
possible to create a feature flag with a null variation by other means, and also since
defaultValue
is nullable, you should assume that the return value might be null.
See Also
| Edit this page View SourceStringVariationDetail(string, Context, string)
Calculates the string value of a feature flag for a given context, and returns an object that describes the way the value was determined.
Declaration
EvaluationDetail<string> StringVariationDetail(string key, Context context, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | the unique feature key for the feature flag |
Context | context | the evaluation context |
string | defaultValue | the default value of the flag |
Returns
Type | Description |
---|---|
EvaluationDetail<string> | an EvaluationDetail<T> object |
Remarks
The Reason property in the result will also be included in analytics events, if you are capturing detailed event data for this flag.
The behavior is otherwise identical to StringVariation(string, Context, string).
See Also
| Edit this page View SourceTrack(string, Context)
Tracks that an application-defined event occurred.
Declaration
void Track(string name, Context context)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the event |
Context | context | the evaluation context associated with the event |
Remarks
This method creates a "custom" analytics event containing the specified event name (key) and context attributes. You may attach arbitrary data to the event by calling Track(string, Context, LdValue) instead.
Note that event delivery is asynchronous, so the event may not actually be sent until later; see Flush().
See Also
| Edit this page View SourceTrack(string, Context, LdValue)
Tracks that an application-defined event occurred.
Declaration
void Track(string name, Context context, LdValue data)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the event |
Context | context | the evaluation context associated with the event |
LdValue | data | additional data associated with the event, if any |
Remarks
This method creates a "custom" analytics event containing the specified event name (key), context properties, and optional custom data. If you do not need custom data, pass Null for the last parameter or simply omit the parameter.
Note that event delivery is asynchronous, so the event may not actually be sent until later; see Flush().
See Also
| Edit this page View SourceTrack(string, Context, LdValue, double)
Tracks that an application-defined event occurred, and provides an additional numeric value for custom metrics.
Declaration
void Track(string name, Context context, LdValue data, double metricValue)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the event |
Context | context | the evaluation context associated with the event |
LdValue | data | additional data associated with the event; use Null if not applicable |
double | metricValue | a numeric value used by the LaunchDarkly experimentation feature in numeric custom metrics |
Remarks
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.
Note that event delivery is asynchronous, so the event may not actually be sent until later; see Flush().
See Also
| Edit this page View SourceTrackMigration(MigrationOpTracker)
Track the details of a migration.
Declaration
void TrackMigration(MigrationOpTracker tracker)
Parameters
Type | Name | Description |
---|---|---|
MigrationOpTracker | tracker | migration tracker which was used to track the details of a migration |