C++ Client-Side SDK
LaunchDarkly SDK
data_source_status.hpp
1 #pragma once
2 
3 #include <chrono>
4 #include <cstddef>
5 #include <cstdint>
6 #include <functional>
7 #include <memory>
8 #include <optional>
9 #include <utility>
10 
11 #include <launchdarkly/connection.hpp>
12 #include <launchdarkly/data_sources/data_source_status_base.hpp>
13 
14 namespace launchdarkly::client_side::data_sources {
15 
19 enum class DataSourceState : std::int32_t {
28  kInitializing = 0,
29 
39  kValid = 1,
40 
51  kInterrupted = 2,
52 
56  kSetOffline = 3,
57 
66  kShutdown = 4
67 };
68 
74 char const* GetDataSourceStateName(DataSourceState state,
75  char const* default_if_unknown);
76 
77 using DataSourceStatus =
78  common::data_sources::DataSourceStatusBase<DataSourceState>;
79 
84  public:
89  [[nodiscard]] virtual DataSourceStatus Status() const = 0;
90 
97  virtual std::unique_ptr<IConnection> OnDataSourceStatusChange(
98  std::function<void(data_sources::DataSourceStatus status)> handler) = 0;
99 
108  virtual std::unique_ptr<IConnection> OnDataSourceStatusChangeEx(
109  std::function<bool(data_sources::DataSourceStatus status)> handler) = 0;
110 
111  virtual ~IDataSourceStatusProvider() = default;
115  delete;
117 
118  protected:
119  IDataSourceStatusProvider() = default;
120 };
121 
122 std::ostream& operator<<(std::ostream& out,
123  DataSourceStatus::DataSourceState const& state);
124 
125 std::ostream& operator<<(std::ostream& out, DataSourceStatus const& status);
126 
127 } // namespace launchdarkly::client_side::data_sources
virtual std::unique_ptr< IConnection > OnDataSourceStatusChangeEx(std::function< bool(data_sources::DataSourceStatus status)> handler)=0
virtual std::unique_ptr< IConnection > OnDataSourceStatusChange(std::function< void(data_sources::DataSourceStatus status)> handler)=0
Definition: data_source_status_base.hpp:12