C++ Server-Side SDK
LaunchDarkly SDK
defaults.hpp
1 #pragma once
2 #include <launchdarkly/config/shared/defaults.hpp>
3 #include <launchdarkly/server_side/config/built/data_system/background_sync_config.hpp>
4 #include <launchdarkly/server_side/config/built/data_system/data_destination_config.hpp>
5 #include <launchdarkly/server_side/config/built/data_system/data_system_config.hpp>
6 #include <launchdarkly/server_side/config/built/data_system/fdv2_config.hpp>
7 #include <launchdarkly/server_side/config/built/data_system/lazy_load_config.hpp>
8 
9 namespace launchdarkly::server_side::config {
10 
11 struct Defaults {
12  // No bootstrap phase yet in server-sdk; instead full
13  // sync is done when polling/streaming source initializes.
14  static auto BootstrapConfig() -> std::optional<built::BootstrapConfig> {
15  return std::nullopt;
16  }
17 
18  // Data isn't mirrored anywhere by default.
19  static auto DataDestinationConfig()
20  -> std::optional<built::DataDestinationConfig> {
21  return std::nullopt;
22  }
23 
24  static auto SynchronizerConfig()
25  -> built::BackgroundSyncConfig::StreamingConfig {
26  return {std::chrono::seconds(1), "/all"};
27  }
28 
29  static auto BackgroundSyncConfig() -> built::BackgroundSyncConfig {
30  return {BootstrapConfig(), SynchronizerConfig(),
31  DataDestinationConfig()};
32  }
33 
34  static auto LazyLoadConfig() -> built::LazyLoadConfig {
35  return {built::LazyLoadConfig::EvictionPolicy::Disabled,
36  std::chrono::minutes{5}, nullptr};
37  }
38 
39  static auto FDv2StreamingConfig() -> built::FDv2Config::StreamingConfig {
40  return {std::chrono::seconds{1}};
41  }
42 
43  static auto FDv2PollingConfig() -> built::FDv2Config::PollingConfig {
44  return {std::chrono::seconds{30}};
45  }
46 
47  static auto FDv2Config() -> built::FDv2Config {
48  using StreamingConfig = built::FDv2Config::StreamingConfig;
49  using PollingConfig = built::FDv2Config::PollingConfig;
50  using SyncVariant = std::variant<StreamingConfig, PollingConfig>;
51  using FallbackVariant =
52  std::variant<built::FDv2Config::FDv1StreamingConfig,
53  built::FDv2Config::FDv1PollingConfig>;
54  return {
55  {FDv2PollingConfig()},
56  std::vector<SyncVariant>{FDv2StreamingConfig(),
57  FDv2PollingConfig()},
59  launchdarkly::config::shared::ServerSDK>::StreamingConfig()},
60  std::chrono::minutes{2},
61  std::chrono::minutes{5}};
62  }
63 
64  static auto DataSystemConfig() -> built::DataSystemConfig {
65  return {false, BackgroundSyncConfig()};
66  }
67 };
68 } // namespace launchdarkly::server_side::config
Definition: defaults.hpp:19