Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Public Member Functions | List of all members
srfm::stream::ReconnectingTickSource< Source > Class Template Reference

Wraps any TickSource with automatic reconnection on read failure. More...

#include <tick_source.hpp>

Public Member Functions

 ReconnectingTickSource (Source source, std::chrono::milliseconds initial_delay=std::chrono::milliseconds{100}, std::chrono::milliseconds max_delay=std::chrono::milliseconds{30 '000})
 
std::optional< OHLCVTick > read ()
 Read the next tick. Returns std::nullopt on transient failure (after sleeping current_delay_). Reconnect is attempted automatically.
 
void reset_backoff () noexcept
 Reset the backoff state without reconnecting the underlying source.
 
Source & source () noexcept
 Access the underlying source (e.g. to re-open a pipe).
 
const Source & source () const noexcept
 

Detailed Description

template<typename Source>
class srfm::stream::ReconnectingTickSource< Source >

Wraps any TickSource with automatic reconnection on read failure.

Uses exponential backoff starting at initial_delay (default 100 ms), doubling each attempt up to max_delay (default 30 000 ms = 30 s). After a successful read the delay resets to initial_delay.

Thread safety: same as the wrapped Source type.

Example
// Create a QueueTickSource wrapped with reconnect logic.
// (Useful in tests to simulate transient read failures.)
QueueTickSource inner;
inner.push(OHLCVTick{...});
std::move(inner),
std::chrono::milliseconds{50}, // initial backoff
std::chrono::milliseconds{5000} // max backoff
);
// Returns nullopt (and sleeps briefly) when the queue is empty;
// returns the tick and resets backoff on success.
while (true) {
auto tick = src.read();
if (tick) process(*tick);
}
Wraps any TickSource with automatic reconnection on read failure.
std::optional< OHLCVTick > read()
Read the next tick. Returns std::nullopt on transient failure (after sleeping current_delay_)....
Single OHLCV bar tick from the market data feed.
Definition tick.hpp:50

Definition at line 295 of file tick_source.hpp.

Constructor & Destructor Documentation

◆ ReconnectingTickSource()

template<typename Source >
srfm::stream::ReconnectingTickSource< Source >::ReconnectingTickSource ( Source  source,
std::chrono::milliseconds  initial_delay = std::chrono::milliseconds{100},
std::chrono::milliseconds  max_delay = std::chrono::milliseconds{30'000} 
)
inlineexplicit

Definition at line 297 of file tick_source.hpp.

Member Function Documentation

◆ read()

template<typename Source >
std::optional< OHLCVTick > srfm::stream::ReconnectingTickSource< Source >::read ( )
inline

Read the next tick. Returns std::nullopt on transient failure (after sleeping current_delay_). Reconnect is attempted automatically.

Definition at line 308 of file tick_source.hpp.

◆ reset_backoff()

template<typename Source >
void srfm::stream::ReconnectingTickSource< Source >::reset_backoff ( )
inlinenoexcept

Reset the backoff state without reconnecting the underlying source.

Definition at line 321 of file tick_source.hpp.

◆ source() [1/2]

template<typename Source >
const Source & srfm::stream::ReconnectingTickSource< Source >::source ( ) const
inlinenoexcept

Definition at line 325 of file tick_source.hpp.

◆ source() [2/2]

template<typename Source >
Source & srfm::stream::ReconnectingTickSource< Source >::source ( )
inlinenoexcept

Access the underlying source (e.g. to re-open a pipe).

Definition at line 324 of file tick_source.hpp.


The documentation for this class was generated from the following file: