C++ Server-Side SDK
LaunchDarkly SDK
|
This interface is used for persisting data to databases, or any other component that can store feature flag / segment data. More...
#include <iserialized_destination.hpp>
Public Types | |
enum class | InitResult { kSuccess , kError } |
enum class | UpsertResult { kSuccess , kError , kNotUpdated } |
using | Key = std::string |
template<typename T > | |
using | Keyed = std::pair< Key, T > |
using | OrderedNamepace = std::vector< Keyed< integrations::SerializedItemDescriptor > > |
using | ItemCollection = std::pair< integrations::ISerializedItemKind const &, OrderedNamepace > |
Public Member Functions | |
virtual InitResult | Init (std::vector< ItemCollection > sdk_data_set)=0 |
Overwrites the Destination's contents with a set of items for each collection. All previous data should be disgraded regardless of versioning. | |
virtual UpsertResult | Upsert (integrations::ISerializedItemKind const &kind, std::string const &key, integrations::SerializedItemDescriptor item)=0 |
Upserts a single item (update if exist, insert if not.) | |
virtual std::string const & | Identity () const =0 |
ISerializedDestination (ISerializedDestination const &item)=delete | |
ISerializedDestination (ISerializedDestination &&item)=delete | |
ISerializedDestination & | operator= (ISerializedDestination const &)=delete |
ISerializedDestination & | operator= (ISerializedDestination &&)=delete |
This interface is used for persisting data to databases, or any other component that can store feature flag / segment data.
The SDK automatically converts between its in-memory data model and a serialized string form, which is what this interface interacts with.
Each item in the store is conceptually a SerializedItemDescriptor containing a version and the serialized form. The serialized form might represent a flag/segment, or a "tombstone" representing the (absence) of an item.
It's possible to satisfy the interface in two ways:
|
pure virtual |
|
pure virtual |
Overwrites the Destination's contents with a set of items for each collection. All previous data should be disgraded regardless of versioning.
The update should be done atomically. If that's not possible, the store must first add or update each item in the same order that they are given in the input data, and then delete any previously stored items that were not in the input data.
sdk_data_set | A series of collections, where each collection is named by an ISerializedItemKind and contains a list of key/value pairs representing the key of the item and the serialized form of the item. |
|
pure virtual |
Upserts a single item (update if exist, insert if not.)
If the given key already exists in the collection named by kind, then the Destination must check the version number corresponding to that key. Note that the item corresponding to that key may be a tombstone representing an absent item.
If the version of the existing item is >= the version of the new item, return UpsertResult::kNotUpdated. If the Destination can't determine the version number of the existing item without full deserialization, then it may call integrations::ISerializedItemKind::Version on the data to obtain it.
If the given item's deleted flag is true, the Destination must persist this fact. It can either store a tombstone (value of serializedItem), or if deletion state is stored separate from the item, it can use that mechanism. In any case, it should not delete/forget about the item.
kind | The item kind. |
key | The item key. |
item | Serialized form of the item. |