Class MessageTruncator
Defined in File message_truncator.hpp
Nested Relationships
Nested Types
Class Documentation
-
class MessageTruncator
Applies the felix-star message size limits to an I/O vector.
Encapsulates the limits imposed by the network: the largest message it can carry and the maximum number of I/O vector entries. Each publish call may ask for a smaller limit of its own. It resolves the effective limit and truncates the message accordingly.
Public Functions
-
std::uint8_t truncate_msg_if_too_large(std::span<iovec> &iov, size_t bytes, std::uint8_t status, std::optional<size_t> max_msg_size = std::nullopt) const
Truncate the message if it is too large and return the updated status.
Changes iov to fit into the effective message size limit and into the configured maximum number of I/O vector entries. A message already within both limits is left untouched.
- Parameters:
iov -- I/O vector describing the message, shortened in place if too large.
bytes -- total message size in bytes, i.e. the sum of the iov entry lengths.
status -- status byte, SW_TRUNC is set if a truncation occurred.
max_msg_size -- per-call limit. If not set, the message is bound only by the network. A larger limit than the network can carry is capped to the latter.
- Returns:
updated status byte.
-
struct Settings
The limits imposed by the network, which no message can exceed.
Meant to be filled with designated initializers, so that the two limits cannot be mixed up: MessageTruncator{{.max_msg_by_net = 4096, .max_iov_len = 32}}
-
std::uint8_t truncate_msg_if_too_large(std::span<iovec> &iov, size_t bytes, std::uint8_t status, std::optional<size_t> max_msg_size = std::nullopt) const