3 #include "data_sources/data_source.hpp"
4 #include "data_sources/data_source_status_manager.hpp"
5 #include "flag_manager/flag_manager.hpp"
7 #include <launchdarkly/client_side/client.hpp>
8 #include <launchdarkly/client_side/data_source_status.hpp>
9 #include <launchdarkly/client_side/flag_notifier.hpp>
10 #include <launchdarkly/config/client.hpp>
11 #include <launchdarkly/context.hpp>
12 #include <launchdarkly/data/evaluation_detail.hpp>
13 #include <launchdarkly/error.hpp>
14 #include <launchdarkly/events/event_processor_interface.hpp>
15 #include <launchdarkly/logging/logger.hpp>
16 #include <launchdarkly/value.hpp>
18 #include <boost/asio/executor_work_guard.hpp>
19 #include <boost/asio/io_context.hpp>
21 #include <condition_variable>
25 #include <shared_mutex>
28 namespace launchdarkly::client_side {
41 [[nodiscard]] std::unordered_map<FlagKey, Value>
AllFlags()
const override;
43 void Track(std::string event_name,
45 double metric_value)
override;
47 void Track(std::string event_name,
Value data)
override;
49 void Track(std::string event_name)
override;
58 bool default_value)
override;
61 std::string default_value)
override;
65 std::string default_value)
override;
71 double default_value)
override;
76 int default_value)
override;
81 Value default_value)
override;
97 void TrackInternal(std::string event_name,
98 std::optional<Value> data,
99 std::optional<double> metric_value);
101 template <
typename F>
102 auto ReadContextSynchronized(F fn)
const
103 -> std::invoke_result_t<F, Context const&> {
104 std::shared_lock lock(context_mutex_);
108 void UpdateContextSynchronized(
Context context);
110 void RestartDataSource();
112 std::future<bool> StartAsyncInternal();
118 boost::asio::io_context ioc_;
119 boost::asio::executor_work_guard<boost::asio::io_context::executor_type>
123 mutable std::shared_mutex context_mutex_;
126 std::function<std::shared_ptr<data_sources::IDataSource>()>
127 data_source_factory_;
129 std::shared_ptr<data_sources::IDataSource> data_source_;
131 std::unique_ptr<events::IEventProcessor> event_processor_;
133 mutable std::mutex init_mutex_;
134 std::condition_variable init_waiter_;
138 std::thread run_thread_;
140 bool eval_reasons_available_;
Definition: context.hpp:29
Definition: evaluation_detail.hpp:18
Definition: client_impl.hpp:29
bool Initialized() const override
Definition: client_impl.cpp:206
std::string StringVariation(FlagKey const &key, std::string default_value) override
Definition: client_impl.cpp:356
Value JsonVariation(FlagKey const &key, Value default_value) override
Definition: client_impl.cpp:389
EvaluationDetail< Value > JsonVariationDetail(FlagKey const &key, Value default_value) override
Definition: client_impl.cpp:383
void FlushAsync() override
Definition: client_impl.cpp:244
flag_manager::IFlagNotifier & FlagNotifier() override
Definition: client_impl.cpp:399
EvaluationDetail< int > IntVariationDetail(FlagKey const &key, int default_value) override
Definition: client_impl.cpp:373
std::future< bool > IdentifyAsync(Context context) override
Definition: client_impl.cpp:161
std::future< bool > StartAsync() override
Definition: client_impl.cpp:202
void Track(std::string event_name, Value data, double metric_value) override
Definition: client_impl.cpp:230
std::unordered_map< FlagKey, Value > AllFlags() const override
Definition: client_impl.cpp:210
EvaluationDetail< std::string > StringVariationDetail(FlagKey const &key, std::string default_value) override
Definition: client_impl.cpp:349
data_sources::IDataSourceStatusProvider & DataSourceStatus() override
Definition: client_impl.cpp:395
bool BoolVariation(FlagKey const &key, bool default_value) override
Definition: client_impl.cpp:344
EvaluationDetail< double > DoubleVariationDetail(FlagKey const &key, double default_value) override
Definition: client_impl.cpp:362
int IntVariation(FlagKey const &key, int default_value) override
Definition: client_impl.cpp:379
double DoubleVariation(FlagKey const &key, double default_value) override
Definition: client_impl.cpp:368
EvaluationDetail< bool > BoolVariationDetail(FlagKey const &key, bool default_value) override
Definition: client_impl.cpp:338
Definition: client.hpp:26
std::string FlagKey
Definition: client.hpp:31
Definition: data_source_status_manager.hpp:17
Definition: data_source_status.hpp:83
Definition: flag_manager.hpp:11
Definition: flag_notifier.hpp:18
Definition: http_properties.hpp:26
Definition: config.hpp:20