Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
slick::sim::md_publisher::SequencedMessage Class Reference

One fan-out payload, serialised once and stamped per subscriber. More...

#include <market_data_publisher/sequenced_message.hpp>

Collaboration diagram for slick::sim::md_publisher::SequencedMessage:

Public Member Functions

 SequencedMessage (nlohmann::json &message)
std::string_view render (uint64_t sequence_num)
 The payload for one subscriber.

Detailed Description

One fan-out payload, serialised once and stamped per subscriber.

Coinbase gives every subscriber its own sequence_num, so a market-data message differs between them by a single integer - but nlohmann has to walk the whole document to produce the text, so dumping inside the per-socket loop re-serialises an identical body once per subscriber. Measured on a ten-level l2_data update with 50 subscribers, dumping once and splicing the number in is ~47x faster.

Hyperliquid does not sequence per subscriber and already sends one shared payload to every socket, so this is only needed on the Coinbase side.

Construction rewrites sequence_num in the document, so the json passed in is consumed - build the message, then wrap it, then fan out.

Definition at line 24 of file sequenced_message.hpp.

Constructor & Destructor Documentation

◆ SequencedMessage()

slick::sim::md_publisher::SequencedMessage::SequencedMessage ( nlohmann::json & message)
inlineexplicit

Definition at line 26 of file sequenced_message.hpp.

Member Function Documentation

◆ render()

std::string_view slick::sim::md_publisher::SequencedMessage::render ( uint64_t sequence_num)
inline

The payload for one subscriber.

The returned view is valid until the next call on this object, which is all ws->send() needs.

Definition at line 50 of file sequenced_message.hpp.


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