26#ifndef ROUTING_CLASSIC_FRAME_INCLUDED
27#define ROUTING_CLASSIC_FRAME_INCLUDED
29#include <system_error>
72 auto num_of_frames = *read_res;
73 if (num_of_frames > 1) {
82 while (!frame_sequence_buf.empty()) {
84 classic_protocol::decode<classic_protocol::frame::Header>(
90 frame_sequence_buf.last(frame_sequence_buf.size() - hdr_res->first);
93 frame_sequence_buf.first(hdr_res->second.payload_size());
95 payload_buf.insert(payload_buf.end(), frame_payload.begin(),
98 frame_sequence_buf = frame_sequence_buf.last(
99 frame_sequence_buf.size() - hdr_res->second.payload_size());
103 classic_protocol::decode<Msg>(
net::buffer(payload_buf), caps);
106 return decode_res->second;
111 classic_protocol::decode<classic_protocol::frame::Frame<Msg>>(
115 return decode_res->second.payload();
122 return recv_msg<Msg>(src_channel, src_protocol,
132 std::forward<Msg>(msg)),
134 if (!encode_res)
return encode_res;
142 return send_msg<Msg>(dst_channel, dst_protocol, std::forward<Msg>(msg),
165 const auto &recv_buf = src_channel->recv_plain_view();
170 if (!frame_decode_res) {
174 src_protocol->seq_id(frame_decode_res->second.seq_id());
176 auto decode_res = classic_protocol::decode<msg_type>(
177 net::buffer(frame_decode_res->second.payload().value()), caps,
178 [src_protocol](
auto stmt_id)
179 ->
stdx::expected<std::vector<msg_type::ParamDef>, std::error_code> {
180 const auto it = src_protocol->prepared_statements().find(stmt_id);
181 if (it == src_protocol->prepared_statements().end()) {
182 return stdx::make_unexpected(make_error_code(
183 classic_protocol::codec_errc::statement_id_not_found));
186 std::vector<msg_type::ParamDef> params;
187 params.reserve(it->second.parameters.size());
189 for (
const auto ¶m : it->second.parameters) {
190 params.emplace_back(param.type_and_flags);
197 return decode_res->second;
SSL aware socket buffers.
Definition: channel.h:64
stdx::expected< size_t, std::error_code > flush_to_send_buf()
flush data to the send buffer.
Definition: channel.cc:152
const recv_buffer_type & payload_buffer() const
payload buffer for
Definition: channel.h:257
recv_buffer_type & send_plain_buffer()
unencrypted data to be sent to the socket.
Definition: channel.cc:277
const recv_view_type & recv_plain_view() const
decrypted data after a recv().
Definition: channel.cc:283
Definition: classic_frame.h:35
static stdx::expected< void, std::error_code > ensure_has_msg_prefix(Channel *src_channel, ClassicProtocolState *src_protocol)
ensure message has a frame-header and msg-type.
Definition: classic_frame.cc:44
static stdx::expected< Msg, std::error_code > recv_msg(Channel *src_channel, ClassicProtocolState *src_protocol)
Definition: classic_frame.h:120
static stdx::expected< void, std::error_code > ensure_frame_header(Channel *src_channel, ClassicProtocolState *src_protocol)
ensure current_frame() has a current frame-info.
Definition: classic_frame.cc:127
static stdx::expected< size_t, std::error_code > send_msg(Channel *dst_channel, ClassicProtocolState *dst_protocol, Msg msg, classic_protocol::capabilities::value_type caps)
Definition: classic_frame.h:127
static stdx::expected< size_t, std::error_code > recv_frame_sequence(Channel *src_channel, ClassicProtocolState *src_protocol)
recv a full message sequence into the channel's recv_plain_buffer()
Definition: classic_frame.cc:172
static constexpr uint8_t cmd_byte()
Definition: classic_frame.h:57
static stdx::expected< size_t, std::error_code > send_msg(Channel *dst_channel, ClassicProtocolState *dst_protocol, Msg msg)
Definition: classic_frame.h:140
static stdx::expected< Msg, std::error_code > recv_msg(Channel *src_channel, ClassicProtocolState *src_protocol, classic_protocol::capabilities::value_type caps)
receive a classic protocol message frame from a channel.
Definition: classic_frame.h:65
static stdx::expected< void, std::error_code > ensure_has_full_frame(Channel *src_channel, ClassicProtocolState *src_protocol)
Definition: classic_frame.cc:152
static stdx::expected< void, std::error_code > ensure_server_greeting(Channel *src_channel, ClassicProtocolState *src_protocol)
protocol state of a classic protocol connection.
Definition: classic_connection_base.h:52
uint8_t & seq_id()
Definition: classic_connection_base.h:118
classic_protocol::capabilities::value_type shared_capabilities() const
Definition: classic_connection_base.h:94
Codec for a type.
Definition: classic_protocol_codec_base.h:72
execute a prepared statement.
Definition: classic_protocol_message.h:1090
Definition: classic_protocol_frame.h:85
Definition: expected.h:944
borrowable::message::client::StmtExecute< true > StmtExecute
Definition: classic_protocol_message.h:1474
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:73
stdx::expected< size_t, std::error_code > encode(const T &v, capabilities::value_type caps, DynamicBuffer &&dyn_buffer)
encode a message into a dynamic buffer.
Definition: classic_protocol_codec_base.h:84
stdx::expected< std::pair< size_t, T >, std::error_code > decode(const net::const_buffer &buffer, capabilities::value_type caps)
decode a message from a buffer.
Definition: classic_protocol_codec_base.h:119
dynamic_vector_buffer< T, Allocator > dynamic_buffer(std::vector< T, Allocator > &vec) noexcept
Definition: buffer.h:663
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
constexpr auto make_unexpected(E &&e) -> unexpected< std::decay_t< E > >
Definition: expected.h:125