C++ Server-Side SDK
LaunchDarkly SDK
data_source_status.hpp
1 #pragma once
2 
3 #include <cstddef>
4 #include <functional>
5 #include <memory>
6 #include <ostream>
7 #include <utility>
8 
9 #include <launchdarkly/connection.hpp>
10 #include <launchdarkly/data_sources/data_source_status_base.hpp>
11 
12 namespace launchdarkly::server_side {
13 
17 enum class DataSourceState {
26  kInitializing = 0,
27 
38  kValid = 1,
39 
50  kInterrupted = 2,
51 
60  kOff = 3,
61 };
62 
63 using DataSourceStatus =
64  common::data_sources::DataSourceStatusBase<DataSourceState>;
65 
70  public:
75  [[nodiscard]] virtual DataSourceStatus Status() const = 0;
76 
83  virtual std::unique_ptr<IConnection> OnDataSourceStatusChange(
84  std::function<void(DataSourceStatus status)> handler) = 0;
85 
94  virtual std::unique_ptr<IConnection> OnDataSourceStatusChangeEx(
95  std::function<bool(DataSourceStatus status)> handler) = 0;
96 
97  virtual ~IDataSourceStatusProvider() = default;
101  delete;
103 
104  protected:
105  IDataSourceStatusProvider() = default;
106 };
107 
108 std::ostream& operator<<(std::ostream& out,
109  DataSourceStatus::DataSourceState const& state);
110 
111 std::ostream& operator<<(std::ostream& out, DataSourceStatus const& status);
112 
113 } // namespace launchdarkly::server_side
Definition: data_source_status_base.hpp:12
Definition: data_source_status.hpp:69
virtual DataSourceStatus Status() const =0
virtual std::unique_ptr< IConnection > OnDataSourceStatusChangeEx(std::function< bool(DataSourceStatus status)> handler)=0
virtual std::unique_ptr< IConnection > OnDataSourceStatusChange(std::function< void(DataSourceStatus status)> handler)=0