C++ Server-Side SDK
LaunchDarkly SDK
data_source_builder.hpp
1 #pragma once
2 
3 #include <launchdarkly/config/shared/built/data_source_config.hpp>
4 #include <launchdarkly/config/shared/defaults.hpp>
5 #include <launchdarkly/config/shared/sdks.hpp>
6 
7 #include <chrono>
8 #include <type_traits>
9 #include <variant>
10 
11 namespace launchdarkly::config::shared::builders {
16 template <typename SDK>
18 
19 template <typename T>
20 struct is_server_sdk : std::false_type {};
21 
22 template <>
23 struct is_server_sdk<ServerSDK> : std::true_type {};
24 
28 template <typename SDK>
30  public:
32 
46  std::chrono::milliseconds initial_reconnect_delay);
47 
65  template <typename T = SDK>
66  std::enable_if_t<is_server_sdk<T>::value, StreamingBuilder&> Filter(
67  std::string filter_key) {
68  config_.filter_key = std::move(filter_key);
69  return *this;
70  }
71 
76  [[nodiscard]] built::StreamingConfig<SDK> Build() const;
77 
78  private:
80 };
81 
85 template <typename SDK>
87  public:
89 
95  PollingBuilder& PollInterval(std::chrono::seconds poll_interval);
96 
115  template <typename T = SDK>
116  std::enable_if_t<is_server_sdk<T>::value, PollingBuilder&> Filter(
117  std::string filter_key) {
118  config_.filter_key = std::move(filter_key);
119  return *this;
120  }
121 
126  [[nodiscard]] built::PollingConfig<SDK> Build() const;
127 
128  private:
130 };
131 
132 template <>
134  public:
137 
139 
151  DataSourceBuilder& WithReasons(bool value);
152 
166  DataSourceBuilder& UseReport(bool value);
167 
179 
190  DataSourceBuilder& Method(Polling polling_builder);
191 
197  [[nodiscard]] built::DataSourceConfig<ClientSDK> Build() const;
198 
199  private:
200  std::variant<Streaming, Polling> method_;
201  bool with_reasons_;
202  bool use_report_;
203 };
204 
205 } // namespace launchdarkly::config::shared::builders
DataSourceBuilder & Method(Streaming stream_builder)
Definition: data_source_builder.hpp:17
Definition: data_source_builder.hpp:86
PollingBuilder & PollInterval(std::chrono::seconds poll_interval)
Definition: data_source_builder.cpp:44
std::enable_if_t< is_server_sdk< T >::value, PollingBuilder & > Filter(std::string filter_key)
Definition: data_source_builder.hpp:116
built::PollingConfig< SDK > Build() const
Definition: data_source_builder.cpp:51
Definition: data_source_builder.hpp:29
std::enable_if_t< is_server_sdk< T >::value, StreamingBuilder & > Filter(std::string filter_key)
Definition: data_source_builder.hpp:66
StreamingBuilder & InitialReconnectDelay(std::chrono::milliseconds initial_reconnect_delay)
Definition: data_source_builder.cpp:28
built::StreamingConfig< SDK > Build() const
Definition: data_source_builder.cpp:35
Definition: data_source_builder.hpp:20
Definition: data_source_config.hpp:36
Definition: data_source_config.hpp:13