3 #include "data_components/status_notifications/data_source_status_manager.hpp"
4 #include "data_interfaces/system/idata_system.hpp"
5 #include "evaluation/evaluator.hpp"
6 #include "events/event_scope.hpp"
8 #include <launchdarkly/config/client.hpp>
9 #include <launchdarkly/context.hpp>
10 #include <launchdarkly/data/evaluation_detail.hpp>
11 #include <launchdarkly/error.hpp>
12 #include <launchdarkly/events/event_processor_interface.hpp>
13 #include <launchdarkly/logging/logger.hpp>
14 #include <launchdarkly/server_side/client.hpp>
15 #include <launchdarkly/value.hpp>
17 #include <boost/asio/executor_work_guard.hpp>
18 #include <boost/asio/io_context.hpp>
20 #include <tl/expected.hpp>
22 #include <condition_variable>
26 #include <shared_mutex>
30 namespace launchdarkly::server_side {
50 std::string event_name,
52 double metric_value)
override;
56 void Track(
Context const& ctx, std::string event_name)
override;
64 bool default_value)
override;
68 bool default_value)
override;
72 std::string default_value)
override;
77 std::string default_value)
override;
81 double default_value)
override;
86 double default_value)
override;
90 int default_value)
override;
94 int default_value)
override;
98 Value default_value)
override;
102 Value default_value)
override;
114 Value const& default_value,
117 template <
typename T>
120 enum Value::Type value_type,
122 Value const& default_value) {
124 VariationInternal(ctx, key, default_value, events_with_reasons_);
125 if (result.Value().Type() == value_type) {
134 enum Value::Type value_type,
135 std::string
const& key,
136 Value const& default_value);
139 std::string
const& key,
141 Value const& default_value,
145 std::optional<data_model::Flag>
const& flag);
147 [[nodiscard]] std::optional<enum EvaluationReason::ErrorKind>
148 PreEvaluationChecks(
Context const& context)
const;
150 void TrackInternal(
Context const& ctx,
151 std::string event_name,
152 std::optional<Value> data,
153 std::optional<double> metric_value);
155 std::future<bool> StartAsyncInternal(
156 std::function<
bool(DataSourceStatus::DataSourceState)> predicate);
158 void LogVariationCall(std::string
const& key,
bool flag_present)
const;
165 boost::asio::io_context ioc_;
166 boost::asio::executor_work_guard<boost::asio::io_context::executor_type>
174 std::unique_ptr<data_interfaces::IDataSystem> data_system_;
176 std::unique_ptr<events::IEventProcessor> event_processor_;
178 mutable std::mutex init_mutex_;
179 std::condition_variable init_waiter_;
186 std::thread run_thread_;
Definition: context.hpp:29
Definition: evaluation_detail.hpp:18
T const & Value() const
Definition: evaluation_detail.cpp:29
ErrorKind
Definition: evaluation_reason.hpp:39
Definition: http_properties.hpp:26
Definition: all_flags_state.hpp:27
Options
Definition: all_flags_state.hpp:29
Definition: client_impl.hpp:32
EvaluationDetail< std::string > StringVariationDetail(Context const &ctx, FlagKey const &key, std::string default_value) override
Definition: client_impl.cpp:385
EvaluationDetail< int > IntVariationDetail(Context const &ctx, FlagKey const &key, int default_value) override
Definition: client_impl.cpp:413
void Track(Context const &ctx, std::string event_name, Value data, double metric_value) override
Definition: client_impl.cpp:234
Value JsonVariation(Context const &ctx, FlagKey const &key, Value default_value) override
Definition: client_impl.cpp:433
double DoubleVariation(Context const &ctx, FlagKey const &key, double default_value) override
Definition: client_impl.cpp:407
EvaluationDetail< bool > BoolVariationDetail(Context const &ctx, FlagKey const &key, bool default_value) override
Definition: client_impl.cpp:372
void Identify(Context context) override
Definition: client_impl.cpp:143
int IntVariation(Context const &ctx, FlagKey const &key, int default_value) override
Definition: client_impl.cpp:420
EvaluationDetail< double > DoubleVariationDetail(Context const &ctx, FlagKey const &key, double default_value) override
Definition: client_impl.cpp:399
void FlushAsync() override
Definition: client_impl.cpp:251
EvaluationDetail< Value > JsonVariationDetail(Context const &ctx, FlagKey const &key, Value default_value) override
Definition: client_impl.cpp:426
std::future< bool > StartAsync() override
Definition: client_impl.cpp:149
std::string StringVariation(Context const &ctx, FlagKey const &key, std::string default_value) override
Definition: client_impl.cpp:393
IDataSourceStatusProvider & DataSourceStatus() override
Definition: client_impl.cpp:439
bool BoolVariation(Context const &ctx, FlagKey const &key, bool default_value) override
Definition: client_impl.cpp:379
bool Initialized() const override
Definition: client_impl.cpp:167
Definition: event_scope.hpp:14
Definition: client.hpp:21
std::string FlagKey
Definition: client.hpp:26
Definition: data_source_status.hpp:69
Definition: data_source_status_manager.hpp:16
Definition: evaluator.hpp:17