FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::BookSyncer< Traits, Sink > Class Template Reference

#include <fastmm/core/book/book_syncer.hpp>

Public Member Functions

 BookSyncer (Sink &sink, std::size_t buffer_bytes=kDefaultBufferBytes)
 
SyncState state () const noexcept
 
bool synced () const noexcept
 
std::uint64_t last_update_id () const noexcept
 
std::uint32_t resync_count () const noexcept
 
std::size_t buffered () const noexcept
 
void start () noexcept
 Begin (or restart) synchronisation.
 
void resync (SyncReason reason) noexcept
 Force a resync (e.g. crossed book beyond grace, or a disconnect).
 
void on_delta (const BookDeltaMsg &d) noexcept
 Delta from the stream.
 
void on_snapshot (const BookDeltaMsg &snap) noexcept
 Snapshot (REST response or in-stream snapshot). Replays the buffer.
 

Static Public Attributes

static constexpr std::size_t kMaxBuffered = 4096
 
static constexpr std::size_t kDefaultBufferBytes = 8U << 20
 

Constructor & Destructor Documentation

◆ BookSyncer()

template<class Traits , class Sink >
fastmm::BookSyncer< Traits, Sink >::BookSyncer ( Sink &  sink,
std::size_t  buffer_bytes = kDefaultBufferBytes 
)
inlineexplicit

Member Function Documentation

◆ state()

template<class Traits , class Sink >
SyncState fastmm::BookSyncer< Traits, Sink >::state ( ) const
inlinenoexcept

◆ synced()

template<class Traits , class Sink >
bool fastmm::BookSyncer< Traits, Sink >::synced ( ) const
inlinenoexcept

◆ last_update_id()

template<class Traits , class Sink >
std::uint64_t fastmm::BookSyncer< Traits, Sink >::last_update_id ( ) const
inlinenoexcept

◆ resync_count()

template<class Traits , class Sink >
std::uint32_t fastmm::BookSyncer< Traits, Sink >::resync_count ( ) const
inlinenoexcept

◆ buffered()

template<class Traits , class Sink >
std::size_t fastmm::BookSyncer< Traits, Sink >::buffered ( ) const
inlinenoexcept

◆ start()

template<class Traits , class Sink >
void fastmm::BookSyncer< Traits, Sink >::start ( )
inlinenoexcept

Begin (or restart) synchronisation.

◆ resync()

template<class Traits , class Sink >
void fastmm::BookSyncer< Traits, Sink >::resync ( SyncReason  reason)
inlinenoexcept

Force a resync (e.g. crossed book beyond grace, or a disconnect).

◆ on_delta()

template<class Traits , class Sink >
void fastmm::BookSyncer< Traits, Sink >::on_delta ( const BookDeltaMsg &  d)
inlinenoexcept

Delta from the stream.

For venues whose stream carries snapshots (Bybit) a message flagged kSnapshot is routed to on_snapshot().

< not started / waiting for start()

No buffered delta was newer than the snapshot, so the first live one must be checked with the first-delta rule: it may overlap the snapshot (U <= L+1 <= u on Binance spot) rather than follow it exactly, and must not be mistaken for a gap.

stale duplicates are silently dropped

◆ on_snapshot()

template<class Traits , class Sink >
void fastmm::BookSyncer< Traits, Sink >::on_snapshot ( const BookDeltaMsg &  snap)
inlinenoexcept

Snapshot (REST response or in-stream snapshot). Replays the buffer.

Find the first non-stale buffered delta; it must bracket L.

Buffered stream starts after the snapshot: the snapshot is too old. Keep buffering and ask again.

keep only the deltas we still need

The stream itself has a gap before d: d and what follows it start the next attempt.

< nothing newer than the snapshot was buffered

Member Data Documentation

◆ kMaxBuffered

template<class Traits , class Sink >
constexpr std::size_t fastmm::BookSyncer< Traits, Sink >::kMaxBuffered = 4096
staticconstexpr

◆ kDefaultBufferBytes

template<class Traits , class Sink >
constexpr std::size_t fastmm::BookSyncer< Traits, Sink >::kDefaultBufferBytes = 8U << 20
staticconstexpr