boost::redis::push_parser
A range that parses Pub/Sub messages from a sequence of RESP3 nodes.
Synopsis
Declared in <boost/redis/push_parser.hpp>
class push_parser;
Description
Given an input range of RESP3 nodes, this class attempts to parse them as Pub/Sub messages. Parsing occurs incrementally, while advancing the iterators.
This type models std::input_range.
This class handles pushes with type message and pmessage with string payloads. These are the messages containing the actual information in the usual Pub/Sub workflow. Any RESP3 message with a different shape will be skipped. In particular, the following message types are skipped:
-
Messages with type other than
resp3::type::push. This includes the output of theMONITORcommand and errors. -
Subscribe and unsubscribe confirmation messages. These happen every time a
SUBSCRIBE,UNSUBSCRIBE,PSUBSCRIBEorPUNSUBSCRIBEcommand is successfully executed, and don't carry application‐level information. -
Pushes with type
messageandpmessagewith a payload type different toresp3::type::blob_string. Client‐side caching generates this kind of messages.
If you need to handle any of these, use the raw RESP3 nodes rather than this class.
Object lifetimes
Iteration state is held by the parser. Iterators reference the parser. The parser must be kept alive for the duration of the iteration.
No copies of the input range are made. The returned push_view values are views.
Example
for (const push_view& msg : push_parser(tree)) {
std::cout << "Channel: " << msg.channel << ", Payload: " << msg.payload << "\n";
}
Member Functions
Name |
Description |
|
Constructs a parser over a range of RESP3 nodes. |
Returns an iterator to the first parsed Pub/Sub message. |
|
Returns a past‐the‐end iterator. |
Created with MrDocs