MySQL 8.4.2
Source Code Documentation
|
This header is internal to the MySQL GCS library and contains metadata information about the message content. More...
#include <gcs_internal_message_headers.h>
Public Member Functions | |
Gcs_internal_message_header () noexcept=default | |
Default constructor which is the only one provided. More... | |
Gcs_internal_message_header (Gcs_internal_message_header &&) noexcept=default | |
These constructors are to be used when move semantics may be needed. More... | |
Gcs_internal_message_header & | operator= (Gcs_internal_message_header &&) noexcept=default |
Gcs_internal_message_header (const Gcs_internal_message_header &) noexcept=default | |
These constructors are to be used when copy semantics may be needed. More... | |
Gcs_internal_message_header & | operator= (const Gcs_internal_message_header &) noexcept=default |
Gcs_protocol_version | get_maximum_version () const |
Gcs_protocol_version | get_used_version () const |
void | set_maximum_version (Gcs_protocol_version version) |
Set the maximum protocol version. More... | |
void | set_used_version (Gcs_protocol_version version) |
Set the current protocol version. More... | |
constexpr unsigned short | get_fixed_header_length () const |
Cargo_type | get_cargo_type () const |
void | set_cargo_type (Cargo_type type) |
Set the cargo type field value. More... | |
unsigned int | get_dynamic_headers_length () const |
void | set_dynamic_headers_length (unsigned int length) |
Set the dynamic headers length field value. More... | |
void | set_payload_length (unsigned long long length) |
Set the message length attribute value according to the payload length and the header length. More... | |
unsigned long long | get_total_length () const |
unsigned long long | decode (const unsigned char *buffer) |
Decode the contents of the buffer and sets the field values according to the values decoded. More... | |
unsigned long long | encode (unsigned char *buffer) const |
Encode the contents of this instance into the buffer. More... | |
void | dump (std::ostringstream &output) const |
Create a string representation of the fixed header to be logged. More... | |
Static Public Member Functions | |
static constexpr unsigned short | calculate_length () |
Static Public Attributes | |
static constexpr unsigned short | WIRE_USED_VERSION_SIZE = 2 |
The used protocol version number length field. More... | |
static constexpr unsigned short | WIRE_MAX_VERSION_SIZE = 2 |
The maximum protocol version number length field. More... | |
static constexpr unsigned short | WIRE_VERSION_SIZE = 4 |
The length of the combined version fields. More... | |
static constexpr unsigned short | WIRE_HD_LEN_SIZE = 2 |
On-the-wire size of the fixed header length field. More... | |
static constexpr unsigned short | WIRE_TOTAL_LEN_SIZE = 8 |
On-the-wire size of the message size field. More... | |
static constexpr unsigned short | WIRE_CARGO_TYPE_SIZE = 2 |
On-the-wire size of the cargo type field. More... | |
static constexpr unsigned short | WIRE_DYNAMIC_HDRS_LEN_SIZE = 4 |
On-the-wire size of the dynamic headers length field. More... | |
static constexpr unsigned short | WIRE_DYNAMIC_HDRS_LEN_OFFSET |
On-the-wire offset of the dynamic headers length field. More... | |
static constexpr unsigned short | WIRE_MSG_LEN_OFFSET |
On-the-wire offset of the message length field. More... | |
static constexpr unsigned short | WIRE_TOTAL_FIXED_HEADER_SIZE |
On-the-wire size of the fixed header. More... | |
Private Attributes | |
Gcs_protocol_version | m_used_version {Gcs_protocol_version::UNKNOWN} |
The header instance used protocol version. More... | |
Gcs_protocol_version | m_max_version {Gcs_protocol_version::UNKNOWN} |
The header instance maximum protocol version. More... | |
unsigned short | m_fixed_header_len {WIRE_TOTAL_FIXED_HEADER_SIZE} |
The header instance length. More... | |
unsigned long long | m_payload_len {0} |
The payload length field. More... | |
unsigned int | m_dynamic_headers_len {0} |
The length of the dynamic headers. More... | |
Cargo_type | m_cargo_type {Cargo_type::CT_UNKNOWN} |
The cargo type code. More... | |
This header is internal to the MySQL GCS library and contains metadata information about the message content.
The on-the-wire representation of the fixed header is:
+---------------—+--------—+---------------------------------------—+ | field | wire size | description | +==================+===========+==========================================+ | used_version | 2 bytes | protocol version in use by sender | | max_version | 2 bytes | max protocol version supported by sender | | fixed_hdr_len | 2 bytes | length of the fixed header | | message_len | 8 bytes | length of the message | | dyn_hdr_len | 4 bytes | length of the dynamic headers | | cargo_type | 2 bytes | the cargo type in the payload | +---------------—+--------—+---------------------------------------—+
Be aware that previously there was a single 4-byte version field. Its semantics were the same of the used_version field.
Older nodes will continue to send messages that, from their point of view, contain the single version field. Older nodes only know protocol version 1. Messages sent by older nodes will be encoded as follows:
used_version = 1 and max_version = 0
This is due to two factors:
This class takes care of messages from old nodes by decoding such messages as:
used_version = 1 and max_version = 1
|
explicitdefaultnoexcept |
Default constructor which is the only one provided.
|
defaultnoexcept |
These constructors are to be used when move semantics may be needed.
|
defaultnoexcept |
These constructors are to be used when copy semantics may be needed.
|
inlinestaticconstexpr |
unsigned long long Gcs_internal_message_header::decode | ( | const unsigned char * | buffer | ) |
Decode the contents of the buffer and sets the field values according to the values decoded.
The buffer MUST be encoded in little endian format.
buffer | The buffer to decode from. |
void Gcs_internal_message_header::dump | ( | std::ostringstream & | output | ) | const |
Create a string representation of the fixed header to be logged.
output | Reference to the output stream where the string will be created. |
unsigned long long Gcs_internal_message_header::encode | ( | unsigned char * | buffer | ) | const |
Encode the contents of this instance into the buffer.
The encoding SHALL be done in little endian format.
buffer | The buffer to encode to. |
Cargo_type Gcs_internal_message_header::get_cargo_type | ( | ) | const |
unsigned int Gcs_internal_message_header::get_dynamic_headers_length | ( | ) | const |
|
inlineconstexpr |
Gcs_protocol_version Gcs_internal_message_header::get_maximum_version | ( | ) | const |
unsigned long long Gcs_internal_message_header::get_total_length | ( | ) | const |
Gcs_protocol_version Gcs_internal_message_header::get_used_version | ( | ) | const |
|
defaultnoexcept |
|
defaultnoexcept |
void Gcs_internal_message_header::set_cargo_type | ( | Cargo_type | type | ) |
Set the cargo type field value.
type | Cargo type to set. |
void Gcs_internal_message_header::set_dynamic_headers_length | ( | unsigned int | length | ) |
Set the dynamic headers length field value.
length | The dynamic headers value. |
void Gcs_internal_message_header::set_maximum_version | ( | Gcs_protocol_version | version | ) |
Set the maximum protocol version.
version | Maximum protocol version. |
void Gcs_internal_message_header::set_payload_length | ( | unsigned long long | length | ) |
Set the message length attribute value according to the payload length and the header length.
Only the payload information is provided because the header length is fixed.
length | Payload length. |
void Gcs_internal_message_header::set_used_version | ( | Gcs_protocol_version | version | ) |
Set the current protocol version.
version | Current protocol version. |
|
private |
The cargo type code.
|
private |
The length of the dynamic headers.
|
private |
The header instance length.
|
private |
The header instance maximum protocol version.
|
private |
The payload length field.
Note that we keep track of the total length indirectly and the storage capacity is determined by the payload length which is the dominant factor.
|
private |
The header instance used protocol version.
|
staticconstexpr |
On-the-wire size of the cargo type field.
|
staticconstexpr |
On-the-wire offset of the dynamic headers length field.
|
staticconstexpr |
On-the-wire size of the dynamic headers length field.
|
staticconstexpr |
On-the-wire size of the fixed header length field.
|
staticconstexpr |
The maximum protocol version number length field.
|
staticconstexpr |
On-the-wire offset of the message length field.
|
staticconstexpr |
On-the-wire size of the fixed header.
|
staticconstexpr |
On-the-wire size of the message size field.
|
staticconstexpr |
The used protocol version number length field.
|
staticconstexpr |
The length of the combined version fields.