C++ Server-Side SDK
LaunchDarkly SDK
Loading...
Searching...
No Matches
idata_reader.hpp
1#pragma once
2
3#include <launchdarkly/data_model/descriptors.hpp>
4
5#include <tl/expected.hpp>
6
7#include <optional>
8#include <string>
9#include <unordered_map>
10
11namespace launchdarkly::server_side::data_interfaces {
12
22 public:
23 using Error = std::string;
24
25 template <typename T>
26 using Single = std::optional<data_model::ItemDescriptor<T>>;
27
28 template <typename T>
29 using SingleResult = tl::expected<Single<T>, Error>;
30
31 template <typename T>
32 using Collection =
33 std::unordered_map<std::string, data_model::ItemDescriptor<T>>;
34
35 template <typename T>
36 using CollectionResult = tl::expected<Collection<T>, Error>;
37
44 [[nodiscard]] virtual SingleResult<data_model::Flag> GetFlag(
45 std::string const& key) const = 0;
46
53 [[nodiscard]] virtual SingleResult<data_model::Segment> GetSegment(
54 std::string const& key) const = 0;
55
61 [[nodiscard]] virtual CollectionResult<data_model::Flag> AllFlags()
62 const = 0;
63
69 [[nodiscard]] virtual CollectionResult<data_model::Segment> AllSegments()
70 const = 0;
71
75 [[nodiscard]] virtual std::string const& Identity() const = 0;
76
80 [[nodiscard]] virtual bool Initialized() const = 0;
81
82 virtual ~IDataReader() = default;
83 IDataReader(IDataReader const& item) = delete;
84 IDataReader(IDataReader&& item) = delete;
85 IDataReader& operator=(IDataReader const&) = delete;
86 IDataReader& operator=(IDataReader&&) = delete;
87
88 protected:
89 IDataReader() = default;
90};
91
92} // namespace launchdarkly::server_side::data_interfaces
IDataReader obtains data on-demand. Calls to obtain data may fail, so the getter methods use tl::expe...
Definition idata_reader.hpp:21
virtual CollectionResult< data_model::Segment > AllSegments() const =0
Attempts to get a collection of all segments.
virtual CollectionResult< data_model::Flag > AllFlags() const =0
Attempts to get a collection of all flags.
virtual std::string const & Identity() const =0
virtual SingleResult< data_model::Segment > GetSegment(std::string const &key) const =0
Attempts to get a segment named by key.
virtual SingleResult< data_model::Flag > GetFlag(std::string const &key) const =0
Attempts to get a flag named by key.