11#pragma once
22
33#include < chrono>
4+ #include < cstdint>
45#include < functional> // function
56#include < memory> // unique_ptr
7+ #include < optional>
68#include < string>
9+ #include < string_view>
710#include < utility> // pair
811#include < vector>
912
1417#include " databento/timeseries.hpp" // MetadataCallback, RecordCallback
1518
1619namespace databento {
20+ // Forward declaration
1721class ILogReceiver ;
22+ class LiveBuilder ;
1823
1924// A client for interfacing with Databento's real-time and intraday replay
2025// market data API. This client provides a threaded event-driven API for
2126// receiving the next record. Unlike Historical, each instance of LiveThreaded
2227// is associated with a particular dataset.
2328class LiveThreaded {
2429 public:
25- enum class ExceptionAction {
30+ enum class ExceptionAction : std:: uint8_t {
2631 // Start a new session. Return this instead of calling `Start`, which would
2732 // cause a deadlock.
2833 Restart,
@@ -32,13 +37,6 @@ class LiveThreaded {
3237 using ExceptionCallback =
3338 std::function<ExceptionAction(const std::exception&)>;
3439
35- LiveThreaded (ILogReceiver* log_receiver, std::string key, std::string dataset,
36- bool send_ts_out, VersionUpgradePolicy upgrade_policy,
37- std::chrono::seconds heartbeat_interval);
38- LiveThreaded (ILogReceiver* log_receiver, std::string key, std::string dataset,
39- std::string gateway, std::uint16_t port, bool send_ts_out,
40- VersionUpgradePolicy upgrade_policy,
41- std::chrono::seconds heartbeat_interval);
4240 LiveThreaded (const LiveThreaded&) = delete ;
4341 LiveThreaded& operator =(const LiveThreaded&) = delete ;
4442 LiveThreaded (LiveThreaded&& other) noexcept ;
@@ -57,7 +55,7 @@ class LiveThreaded {
5755 VersionUpgradePolicy UpgradePolicy () const ;
5856 // The the first member of the pair will be true, when the heartbeat interval
5957 // was overridden.
60- std::pair< bool , std::chrono::seconds> HeartbeatInterval () const ;
58+ std::optional< std::chrono::seconds> HeartbeatInterval () const ;
6159 const std::vector<LiveSubscription>& Subscriptions () const ;
6260 std::vector<LiveSubscription>& Subscriptions ();
6361
@@ -96,15 +94,27 @@ class LiveThreaded {
9694 KeepGoing BlockForStop (std::chrono::milliseconds timeout);
9795
9896 private:
97+ friend LiveBuilder;
98+
9999 struct Impl ;
100100
101101 static void ProcessingThread (Impl* impl, MetadataCallback&& metadata_callback,
102102 RecordCallback&& record_callback,
103103 ExceptionCallback&& exception_callback);
104104 static ExceptionAction ExceptionHandler (
105105 Impl* impl, const ExceptionCallback& exception_callback,
106- const std::exception& exc, const char * pretty_function_name,
107- const char * message);
106+ const std::exception& exc, std::string_view pretty_function_name,
107+ std::string_view message);
108+
109+ LiveThreaded (ILogReceiver* log_receiver, std::string key, std::string dataset,
110+ bool send_ts_out, VersionUpgradePolicy upgrade_policy,
111+ std::optional<std::chrono::seconds> heartbeat_interval,
112+ std::size_t buffer_size);
113+ LiveThreaded (ILogReceiver* log_receiver, std::string key, std::string dataset,
114+ std::string gateway, std::uint16_t port, bool send_ts_out,
115+ VersionUpgradePolicy upgrade_policy,
116+ std::optional<std::chrono::seconds> heartbeat_interval,
117+ std::size_t buffer_size);
108118
109119 // unique_ptr to be movable
110120 std::unique_ptr<Impl> impl_;
0 commit comments