26#ifndef MYSQL_ROUTER_CLASSIC_PROTOCOL_CODEC_SESSION_TRACK_H_
27#define MYSQL_ROUTER_CLASSIC_PROTOCOL_CODEC_SESSION_TRACK_H_
48 Codec<borrowable::session_track::TransactionState>> {
49 template <
class Accumulator>
51 namespace bw = borrowable::wire;
54 .step(bw::FixedInt<1>(0x08))
55 .step(bw::FixedInt<1>(v_.trx_type()))
56 .step(bw::FixedInt<1>(v_.read_unsafe()))
57 .step(bw::FixedInt<1>(v_.read_trx()))
58 .step(bw::FixedInt<1>(v_.write_unsafe()))
59 .step(bw::FixedInt<1>(v_.write_trx()))
60 .step(bw::FixedInt<1>(v_.stmt_unsafe()))
61 .step(bw::FixedInt<1>(v_.resultset()))
62 .step(bw::FixedInt<1>(v_.locked_tables()))
75 constexpr static uint8_t
type_byte() {
return 0x05; }
92 namespace bw = borrowable::wire;
94 const auto payload_length_res = accu.template step<bw::VarInt>();
97 if (payload_length_res->value() != 0x08) {
102 const auto trx_type_res = accu.template step<bw::FixedInt<1>>();
103 const auto read_unsafe_res = accu.template step<bw::FixedInt<1>>();
104 const auto read_trx_res = accu.template step<bw::FixedInt<1>>();
105 const auto write_unsafe_res = accu.template step<bw::FixedInt<1>>();
106 const auto write_trx_res = accu.template step<bw::FixedInt<1>>();
107 const auto stmt_unsafe_res = accu.template step<bw::FixedInt<1>>();
108 const auto resultset_res = accu.template step<bw::FixedInt<1>>();
109 const auto locked_tables_res = accu.template step<bw::FixedInt<1>>();
113 return std::make_pair(
115 value_type(trx_type_res->value(), read_unsafe_res->value(),
116 read_trx_res->value(), write_unsafe_res->value(),
117 write_trx_res->value(), stmt_unsafe_res->value(),
118 resultset_res->value(), locked_tables_res->value()));
130template <
bool Borrowed>
133 borrowable::session_track::TransactionCharacteristics<Borrowed>>> {
134 template <
class Accumulator>
136 namespace bw = borrowable::wire;
138 return accu.step(bw::VarString<Borrowed>(v_.characteristics())).result();
168 namespace bw = borrowable::wire;
170 auto characteristics_res = accu.template step<bw::VarString<Borrowed>>();
190 template <
class Accumulator>
192 namespace bw = borrowable::wire;
194 return accu.step(bw::FixedInt<1>(v_.state())).result();
223 namespace bw = borrowable::wire;
225 auto state_res = accu.template step<bw::FixedInt<1>>();
242template <
bool Borrowed>
245 Codec<borrowable::session_track::Schema<Borrowed>>> {
246 template <
class Accumulator>
248 namespace bw = borrowable::wire;
250 return accu.step(bw::VarString<Borrowed>(v_.schema())).result();
279 namespace bw = borrowable::wire;
281 auto schema_res = accu.template step<bw::VarString<Borrowed>>();
298template <
bool Borrowed>
301 Codec<borrowable::session_track::SystemVariable<Borrowed>>> {
302 template <
class Accumulator>
304 namespace bw = borrowable::wire;
306 return accu.step(bw::VarString<Borrowed>(v_.key()))
307 .step(bw::VarString<Borrowed>(v_.value()))
337 namespace bw = borrowable::wire;
339 auto key_res = accu.template step<bw::VarString<Borrowed>>();
340 auto value_res = accu.template step<bw::VarString<Borrowed>>();
345 value_type(key_res->value(), value_res->value()));
365template <
bool Borrowed>
368 Codec<borrowable::session_track::Gtid<Borrowed>>> {
369 template <
class Accumulator>
371 namespace bw = borrowable::wire;
373 return accu.step(bw::FixedInt<1>(v_.spec()))
374 .step(bw::VarString<Borrowed>(v_.gtid()))
404 namespace bw = borrowable::wire;
406 auto spec_res = accu.template step<bw::FixedInt<1>>();
407 auto gtid_res = accu.template step<bw::VarString<Borrowed>>();
412 value_type(spec_res->value(), gtid_res->value()));
436template <
bool Borrowed>
439 Codec<borrowable::session_track::Field<Borrowed>>> {
440 template <
class Accumulator>
442 namespace bw = borrowable::wire;
444 return accu.step(bw::FixedInt<1>(v_.type()))
445 .step(bw::VarString<Borrowed>(v_.data()))
474 namespace bw = borrowable::wire;
476 auto type_res = accu.template step<bw::FixedInt<1>>();
477 auto data_res = accu.template step<bw::VarString<Borrowed>>();
482 value_type(type_res->value(), data_res->value()));
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::Field from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:470
const value_type v_
Definition: classic_protocol_codec_session_track.h:486
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:456
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:441
friend __base
Definition: classic_protocol_codec_session_track.h:454
constexpr static uint8_t type_byte()
Definition: classic_protocol_codec_session_track.h:387
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:384
const value_type v_
Definition: classic_protocol_codec_session_track.h:416
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::Gtid from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:400
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:370
friend __base
Definition: classic_protocol_codec_session_track.h:382
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::Schema from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:275
friend __base
Definition: classic_protocol_codec_session_track.h:257
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:259
const value_type v_
Definition: classic_protocol_codec_session_track.h:290
constexpr static uint8_t type_byte()
Definition: classic_protocol_codec_session_track.h:262
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:247
friend __base
Definition: classic_protocol_codec_session_track.h:315
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::SystemVariable from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:333
const value_type v_
Definition: classic_protocol_codec_session_track.h:349
constexpr static uint8_t type_byte()
Definition: classic_protocol_codec_session_track.h:320
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:303
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:317
friend __base
Definition: classic_protocol_codec_session_track.h:146
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:148
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:135
constexpr static uint8_t type_byte()
Definition: classic_protocol_codec_session_track.h:151
const value_type v_
Definition: classic_protocol_codec_session_track.h:179
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::TransactionCharacteristics from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:164
friend __base
Definition: classic_protocol_codec_session_track.h:70
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::TransactionState from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:88
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:72
const value_type v_
Definition: classic_protocol_codec_session_track.h:122
constexpr static uint8_t type_byte()
Definition: classic_protocol_codec_session_track.h:75
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:50
friend __base
Definition: classic_protocol_codec_session_track.h:201
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a session_track::State from a buffer-sequence.
Definition: classic_protocol_codec_session_track.h:219
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_session_track.h:203
constexpr static uint8_t type_byte()
Definition: classic_protocol_codec_session_track.h:206
const value_type v_
Definition: classic_protocol_codec_session_track.h:234
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_session_track.h:191
Codec for a type.
Definition: classic_protocol_codec_base.h:72
Field of a session-track array.
Definition: classic_protocol_session_track.h:44
gtid changed.
Definition: classic_protocol_session_track.h:145
schema changed.
Definition: classic_protocol_session_track.h:98
state changed.
Definition: classic_protocol_session_track.h:121
system-variable changed.
Definition: classic_protocol_session_track.h:71
TransactionCharacteristics changed.
Definition: classic_protocol_session_track.h:248
TransactionState changed.
Definition: classic_protocol_session_track.h:194
Generator of decoded Types of a buffer.
Definition: classic_protocol_codec_base.h:153
result_type result() const
get result of the step().
Definition: classic_protocol_codec_base.h:219
CRTP base for the Codec's encode part.
Definition: classic_protocol_codec_base.h:375
constexpr const value_type & value() const &
Definition: expected.h:688
constexpr unexpected_type get_unexpected() const
Definition: expected.h:754
constexpr const error_type & error() const &
Definition: expected.h:737
Definition: expected.h:944
borrowable::session_track::State State
Definition: classic_protocol_session_track.h:278
borrowable::session_track::TransactionState TransactionState
Definition: classic_protocol_session_track.h:275
constexpr value_type session_track
Definition: classic_protocol_constants.h:61
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:73
borrowable::session_track::State State
Definition: classic_protocol_session_track.h:290
Definition: classic_protocol_binary.h:39
std::error_code make_error_code(codec_errc e) noexcept
Definition: classic_protocol_codec_error.h:86
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
Definition: gcs_xcom_synode.h:64
constexpr auto make_unexpected(E &&e) -> unexpected< std::decay_t< E > >
Definition: expected.h:125