C++ Client-Side SDK
LaunchDarkly SDK
persistence_builder.hpp
1 #pragma once
2 
3 #include <chrono>
4 #include <memory>
5 #include <optional>
6 #include <type_traits>
7 #include <variant>
8 
9 #include <launchdarkly/config/shared/built/persistence.hpp>
10 #include <launchdarkly/config/shared/defaults.hpp>
11 #include <launchdarkly/config/shared/sdks.hpp>
12 #include <launchdarkly/persistence/persistence.hpp>
13 
14 namespace launchdarkly::config::shared::builders {
15 template <typename SDK>
17 
18 template <>
20  public:
21  class NoneBuilder {};
22 
23  class CustomBuilder {
24  public:
31  CustomBuilder& Implementation(
32  std::shared_ptr<IPersistence> implementation);
33 
34  private:
35  std::shared_ptr<IPersistence> implementation_;
36  friend class PersistenceBuilder;
37  };
38 
39  using PersistenceType = std::variant<NoneBuilder, CustomBuilder>;
40 
42 
52  PersistenceBuilder& Type(PersistenceType persistence);
53 
59  PersistenceBuilder& Custom(std::shared_ptr<IPersistence> implementation);
60 
65  PersistenceBuilder& None();
66 
75  PersistenceBuilder& MaxContexts(std::size_t count);
76 
77  [[nodiscard]] built::Persistence<ClientSDK> Build() const;
78 
79  private:
80  PersistenceType type_;
81  std::size_t max_contexts_;
82 };
83 
84 } // namespace launchdarkly::config::shared::builders