C Server-Side SDK
LaunchDarkly SDK
store.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <stddef.h>
9 
10 #include <launchdarkly/boolean.h>
11 
12 /*******************************************************************************
13  * @name Store collections and individual items.
14  * Used to provide an opaque interface for interacting with feature values.
15  * @{
16  ******************************************************************************/
17 
20 {
22  void * buffer;
23  size_t bufferSize;
24  unsigned int version;
25 };
26 
29 {
30  const char * key;
31  struct LDStoreCollectionItem item;
32 };
33 
36 {
37  const char * kind;
38  struct LDStoreCollectionStateItem *items;
39  unsigned int itemCount;
40 };
41 
44 /*******************************************************************************
45  * @name Generic Store Interface
46  * Used to provide all interaction with a feature store. Redis, Consul, Dynamo.
47  *
48  * The associated functions use a boolean result to indicate success, or error
49  * outside of expected functionality. For example a memory allocation error
50  * would return false, but `get` on a non existent item would return true.
51  * @{
52  ******************************************************************************/
53 
60 {
64  void *context;
72  LDBoolean (*init)(
73  void *const context,
74  const struct LDStoreCollectionState *collections,
75  const unsigned int collectionCount);
87  LDBoolean (*get)(
88  void *const context,
89  const char *const kind,
90  const char *const featureKey,
91  struct LDStoreCollectionItem *const result);
102  LDBoolean (*all)(
103  void *const context,
104  const char *const kind,
105  struct LDStoreCollectionItem **const result,
106  unsigned int *const resultCount);
119  LDBoolean (*upsert)(
120  void *const context,
121  const char *const kind,
122  const struct LDStoreCollectionItem *const feature,
123  const char *const featureKey);
130  LDBoolean (*initialized)(void *const context);
137  void (*destructor)(void *const context);
138 };
139 
LDStoreCollectionState
Stores the set of items in a single namespace.
Definition: store.h:35
LDStoreInterface::context
void * context
Used to store implementation specific data.
Definition: store.h:64
boolean.h
A custom c89 boolean type.
LDStoreInterface
An opaque client object.
Definition: store.h:59
LDStoreInterface::upsert
LDBoolean(* upsert)(void *const context, const char *const kind, const struct LDStoreCollectionItem *const feature, const char *const featureKey)
Replace an existing feature with a newer one or delete a feature.
Definition: store.h:119
LDStoreCollectionStateItem
Stores a single item and its key.
Definition: store.h:28
LDStoreInterface::get
LDBoolean(* get)(void *const context, const char *const kind, const char *const featureKey, struct LDStoreCollectionItem *const result)
Fetch a feature from the store.
Definition: store.h:87
LDStoreInterface::init
LDBoolean(* init)(void *const context, const struct LDStoreCollectionState *collections, const unsigned int collectionCount)
Initialize the feature store with a new data set.
Definition: store.h:72
LDStoreInterface::all
LDBoolean(* all)(void *const context, const char *const kind, struct LDStoreCollectionItem **const result, unsigned int *const resultCount)
Fetch all features in a given namespace.
Definition: store.h:102
LDStoreCollectionItem::buffer
void * buffer
May be NULL to indicate a deleted item.
Definition: store.h:26
LDStoreInterface::destructor
void(* destructor)(void *const context)
Destroy the implementation specific context associated.
Definition: store.h:137
LDStoreCollectionItem
Opaque value representing an item.
Definition: store.h:19
LDStoreInterface::initialized
LDBoolean(* initialized)(void *const context)
Determine if the store is initialized with features yet.
Definition: store.h:130