C Server-Side SDK
LaunchDarkly SDK
variations.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <launchdarkly/boolean.h>
9 #include <launchdarkly/client.h>
10 #include <launchdarkly/export.h>
11 #include <launchdarkly/json.h>
12 #include <launchdarkly/user.h>
14 
17 {
39 };
40 
43 {
67 };
68 
71 {
73  unsigned int ruleIndex;
75  char *id;
79  LDBoolean inExperiment;
80 };
81 
84 {
88  LDBoolean inExperiment;
89 };
90 
91 struct LDDetails
92 {
95  unsigned int variationIndex;
98  LDBoolean hasVariation;
102  union {
111  } extra;
112 };
113 
115 LD_EXPORT(void) LDDetailsInit(struct LDDetails *const details);
116 
118 LD_EXPORT(void) LDDetailsClear(struct LDDetails *const details);
119 
127 LD_EXPORT(const char *) LDEvalReasonKindToString(const enum LDEvalReason kind);
128 
134 LD_EXPORT(const char *)
136 
143 LD_EXPORT(struct LDJSON *)
144 LDReasonToJSON(const struct LDDetails *const details);
145 
156 LD_EXPORT(LDBoolean)
158  struct LDClient *const client,
159  const struct LDUser *const user,
160  const char *const key,
161  const LDBoolean fallback,
162  struct LDDetails *const details);
163 
174 LD_EXPORT(int)
176  struct LDClient *const client,
177  const struct LDUser *const user,
178  const char *const key,
179  const int fallback,
180  struct LDDetails *const details);
181 
192 LD_EXPORT(double)
194  struct LDClient *const client,
195  const struct LDUser *const user,
196  const char *const key,
197  const double fallback,
198  struct LDDetails *const details);
199 
213 LD_EXPORT(char *)
215  struct LDClient *const client,
216  const struct LDUser *const user,
217  const char *const key,
218  const char *const fallback,
219  struct LDDetails *const details);
220 
234 LD_EXPORT(struct LDJSON *)
236  struct LDClient *const client,
237  const struct LDUser *const user,
238  const char *const key,
239  const struct LDJSON *const fallback,
240  struct LDDetails *const details);
241 
251 LD_EXPORT(struct LDJSON *)
252 LDAllFlags(struct LDClient *const client, const struct LDUser *const user);
253 
254 
255 
266 LD_EXPORT(struct LDAllFlagsState *)
267 LDAllFlagsState(struct LDClient *const client, const struct LDUser *const user, unsigned int options);
LD_OFF
@ LD_OFF
Indicates that the flag was off and therefore returned its configured off value.
Definition: variations.h:26
LDEvalErrorKind
LDEvalErrorKind
Details about the type of error that caused an evaluation to fail.
Definition: variations.h:42
LDDetails::fallthrough
struct LDDetailsFallthrough fallthrough
when reason == LD_FALLTHROUGH
Definition: variations.h:110
boolean.h
A custom c89 boolean type.
LD_MALFORMED_FLAG
@ LD_MALFORMED_FLAG
Indicates that there was an internal inconsistency in the flag data, a rule specified a nonexistent v...
Definition: variations.h:61
LDDetailsRule::inExperiment
LDBoolean inExperiment
Whether the evaluation was part of an experiment. Is true if the evaluation resulted in an experiment...
Definition: variations.h:79
LD_FALLTHROUGH
@ LD_FALLTHROUGH
Indicates that the flag was on but the user did not match any targets or rules.
Definition: variations.h:38
LD_RULE_MATCH
@ LD_RULE_MATCH
Indicates that the user matched one of the flag's rules.
Definition: variations.h:35
LDBoolVariation
LDBoolean LDBoolVariation(struct LDClient *const client, const struct LDUser *const user, const char *const key, const LDBoolean fallback, struct LDDetails *const details)
Evaluate a boolean flag.
LDDetailsFallthrough
Extra information when reason == LD_FALLTHROUGH.
Definition: variations.h:83
LDAllFlagsState
struct LDAllFlagsState * LDAllFlagsState(struct LDClient *const client, const struct LDUser *const user, unsigned int options)
AllFlagsState returns an object that encapsulates the state of all feature flags for a given user....
LDDetailsClear
void LDDetailsClear(struct LDDetails *const details)
Free any resources associated with details
LDStringVariation
char * LDStringVariation(struct LDClient *const client, const struct LDUser *const user, const char *const key, const char *const fallback, struct LDDetails *const details)
Evaluate a text flag.
LD_FLAG_NOT_FOUND
@ LD_FLAG_NOT_FOUND
Indicates that the caller provided a flag key that did not match any known flag.
Definition: variations.h:53
LDDetails::variationIndex
unsigned int variationIndex
The index of the returned value within the flag's list of variations.
Definition: variations.h:95
LDIntVariation
int LDIntVariation(struct LDClient *const client, const struct LDUser *const user, const char *const key, const int fallback, struct LDDetails *const details)
Evaluate a integer flag.
LD_PREREQUISITE_FAILED
@ LD_PREREQUISITE_FAILED
Indicates that the flag was considered off because it had at least one prerequisite flag that either ...
Definition: variations.h:30
LD_STORE_ERROR
@ LD_STORE_ERROR
Indicates an internal exception with the flag store.
Definition: variations.h:50
LD_ERROR
@ LD_ERROR
Indicates that the flag could not be evaluated, e.g. because it does not exist or due to an unexpecte...
Definition: variations.h:23
LD_CLIENT_NOT_SPECIFIED
@ LD_CLIENT_NOT_SPECIFIED
Indicates that a NULL client was passed for the client parameter.
Definition: variations.h:58
LDDetailsFallthrough::inExperiment
LDBoolean inExperiment
Whether the evaluation was part of an experiment. Is true if the evaluation resulted in an experiment...
Definition: variations.h:88
LD_CLIENT_NOT_READY
@ LD_CLIENT_NOT_READY
Indicates that the caller tried to evaluate a flag before the client had successfully initialized.
Definition: variations.h:46
flag_state.h
Public API associated with LDAllFlagsState.
LDDetailsInit
void LDDetailsInit(struct LDDetails *const details)
Initialize details to a default value.
LD_OOM
@ LD_OOM
Evaluation failed because the client ran out of memory.
Definition: variations.h:66
LDEvalErrorKindToString
const char * LDEvalErrorKindToString(const enum LDEvalErrorKind kind)
Converts an LDEvalErrorKind enum to an equivalent string.
LDEvalReason
LDEvalReason
The reason an evaluation occurred.
Definition: variations.h:16
LD_EXPORT
#define LD_EXPORT(x)
Used to ensure only intended symbols are exported in the binaries.
Definition: export.h:10
LDUser
An opaque user object.
LDReasonToJSON
struct LDJSON * LDReasonToJSON(const struct LDDetails *const details)
Marshal just the evaluation reason portion of LDDetails to JSON.
LDDetailsRule::ruleIndex
unsigned int ruleIndex
The index of the rule that was matched.
Definition: variations.h:73
LD_TARGET_MATCH
@ LD_TARGET_MATCH
Indicates that the user key was specifically targeted for this flag.
Definition: variations.h:33
LD_UNKNOWN
@ LD_UNKNOWN
A default unset reason.
Definition: variations.h:19
LD_NULL_KEY
@ LD_NULL_KEY
Indicates a NULL flag key was used.
Definition: variations.h:48
LDDetails
Definition: variations.h:91
LDJSONVariation
struct LDJSON * LDJSONVariation(struct LDClient *const client, const struct LDUser *const user, const char *const key, const struct LDJSON *const fallback, struct LDDetails *const details)
Evaluate a JSON flag.
LDDetails::rule
struct LDDetailsRule rule
when reason == LD_RULE_MATCH
Definition: variations.h:108
LDDoubleVariation
double LDDoubleVariation(struct LDClient *const client, const struct LDUser *const user, const char *const key, const double fallback, struct LDDetails *const details)
Evaluate a double flag.
LDDetails::reason
enum LDEvalReason reason
The reason an evaluation occurred.
Definition: variations.h:100
LD_WRONG_TYPE
@ LD_WRONG_TYPE
Indicates that the result value was not of the requested type, e.g. you called LDBoolVariation but th...
Definition: variations.h:64
LDDetails::prerequisiteKey
char * prerequisiteKey
when reason == LD_PREREQUISITE_FAILED
Definition: variations.h:106
user.h
Public API Interface for User construction.
LDClient
An opaque client object.
LDDetails::hasVariation
LDBoolean hasVariation
True if there is a variationIndex, false if the default value was returned.
Definition: variations.h:98
json.h
Public API Interface for JSON usage.
LDDetailsRule::id
char * id
The unique identifier of the rule that was matched.
Definition: variations.h:75
LD_USER_NOT_SPECIFIED
@ LD_USER_NOT_SPECIFIED
Indicates that a NULL user was passed for the user parameter.
Definition: variations.h:55
LDDetails::errorKind
enum LDEvalErrorKind errorKind
when reason == LD_ERROR
Definition: variations.h:104
LDEvalReasonKindToString
const char * LDEvalReasonKindToString(const enum LDEvalReason kind)
Convert an LDEvalReason enum to an equivalent string.
LDDetails::extra
union LDDetails::@0 extra
Extra information depending on the evaluation reason.
LDDetailsRule
Indicates which rule matched a user.
Definition: variations.h:70
LDAllFlags
struct LDJSON * LDAllFlags(struct LDClient *const client, const struct LDUser *const user)
Returns a map from feature flag keys to values for a given user. This does not send analytics events ...
client.h
Public API for Client operations.
export.h
Public. Configuration of exported symbols.