C++ Client-Side SDK
LaunchDarkly SDK
Loading...
Searching...
No Matches
polling_data_source.hpp
1#pragma once
2
3#include "data_source.hpp"
4#include "data_source_event_handler.hpp"
5#include "data_source_status_manager.hpp"
6#include "data_source_update_sink.hpp"
7
8#include <launchdarkly/config/shared/built/data_source_config.hpp>
9#include <launchdarkly/config/shared/built/http_properties.hpp>
10#include <launchdarkly/config/shared/built/service_endpoints.hpp>
11#include <launchdarkly/logging/logger.hpp>
12#include <launchdarkly/network/asio_requester.hpp>
13
14#include <chrono>
15
16#include <boost/asio/any_io_executor.hpp>
17
18namespace launchdarkly::client_side::data_sources {
19
21 : public IDataSource,
22 public std::enable_shared_from_this<PollingDataSource> {
23 public:
27 config::shared::ClientSDK> const& data_source_config,
28 config::shared::built::HttpProperties const& http_properties,
29 boost::asio::any_io_executor ioc,
30 Context const& context,
31 IDataSourceUpdateSink& handler,
32 DataSourceStatusManager& status_manager,
33 Logger const& logger);
34
35 void Start() override;
36 void ShutdownAsync(std::function<void()>) override;
37
38 private:
39 void DoPoll();
40 void HandlePollResult(network::HttpResult res);
41
42 std::string string_context_;
43 DataSourceStatusManager& status_manager_;
44 DataSourceEventHandler data_source_handler_;
45 std::string polling_endpoint_;
46
47 network::AsioRequester requester_;
48 Logger const& logger_;
49 boost::asio::any_io_executor ioc_;
50 std::chrono::seconds polling_interval_;
51 network::HttpRequest request_;
52 std::optional<std::string> etag_;
53
54 boost::asio::steady_timer timer_;
55 std::chrono::time_point<std::chrono::system_clock> last_poll_start_;
56
57 void StartPollingTimer();
58};
59
60} // namespace launchdarkly::client_side::data_sources
Definition context.hpp:29
Definition data_source_update_sink.hpp:21
Definition data_source_event_handler.hpp:22
Definition data_source_status_manager.hpp:17
Definition data_source_config.hpp:55