C++ Server-Side SDK
LaunchDarkly SDK
evaluator.hpp
1 #pragma once
2 
3 #include <launchdarkly/context.hpp>
4 #include <launchdarkly/data/evaluation_detail.hpp>
5 #include <launchdarkly/data_model/flag.hpp>
6 #include <launchdarkly/logging/logger.hpp>
7 #include <launchdarkly/value.hpp>
8 
9 #include "evaluation_error.hpp"
10 #include "evaluation_stack.hpp"
11 
12 #include "../data_interfaces/store/istore.hpp"
13 #include "../events/event_scope.hpp"
14 
15 namespace launchdarkly::server_side::evaluation {
16 
17 class Evaluator {
18  public:
28  Evaluator(
29  Logger& logger,
30  data_interfaces::IStore const& source,
31  data_components::BigSegmentStoreWrapper* big_segment_store = nullptr);
32 
43  data_model::Flag const& flag,
44  Context const& context,
45  EventScope const& event_scope);
46 
54  [[nodiscard]] EvaluationDetail<Value> Evaluate(data_model::Flag const& flag,
55  Context const& context);
56 
57  private:
58  [[nodiscard]] EvaluationDetail<Value> Evaluate(
59  std::optional<std::string> parent_key,
60  data_model::Flag const& flag,
61  Context const& context,
62  EvaluationStack& stack,
63  EventScope const& event_scope);
64 
65  [[nodiscard]] EvaluationDetail<Value> FlagVariation(
66  data_model::Flag const& flag,
67  data_model::Flag::Variation variation_index,
68  EvaluationReason reason) const;
69 
70  [[nodiscard]] EvaluationDetail<Value> OffValue(
71  data_model::Flag const& flag,
72  EvaluationReason reason) const;
73 
74  void LogError(std::string const& key, Error const& error) const;
75 
76  Logger& logger_;
77  data_interfaces::IStore const& source_;
78  data_components::BigSegmentStoreWrapper* big_segment_store_;
79 };
80 } // namespace launchdarkly::server_side::evaluation
Definition: context.hpp:29
Definition: evaluation_detail.hpp:18
Definition: evaluation_reason.hpp:13
Definition: event_scope.hpp:14
Internal layer between the evaluator and a customer-provided integrations::IBigSegmentStore.
Definition: big_segment_store_wrapper.hpp:44
IStore provides shared ownership of flag and segment domain objects.
Definition: istore.hpp:15
Definition: evaluation_error.hpp:9
EvaluationDetail< Value > Evaluate(data_model::Flag const &flag, Context const &context, EventScope const &event_scope)
Evaluator(Logger &logger, data_interfaces::IStore const &source, data_components::BigSegmentStoreWrapper *big_segment_store=nullptr)
Definition: evaluator.cpp:39