Skip to content

Commit

Permalink
[coro_rpc][breakchange] change err_code to 16bit
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Dec 26, 2023
1 parent d669b58 commit 746b598
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
3 changes: 0 additions & 3 deletions include/ylt/coro_rpc/impl/coro_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
#include <atomic>
#include <cstdint>
#include <functional>
#include <future>
#include <memory>
#include <string_view>
#include <system_error>
#include <utility>
#include <variant>
#include <vector>
#include <ylt/easylog.hpp>

#include "ylt/coro_io/coro_io.hpp"
Expand Down
6 changes: 3 additions & 3 deletions include/ylt/coro_rpc/impl/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <ylt/struct_pack/util.h>
#pragma once
namespace coro_rpc {
enum class errc : uint8_t {
enum class errc : uint16_t {
ok,
io_error,
not_connected,
Expand All @@ -29,8 +29,8 @@ enum class errc : uint8_t {
protocol_error,
message_too_large,
server_has_ran,
user_defined_err_min = 100,
user_defined_err_max = 255
user_defined_err_min = 256,
user_defined_err_max = 65535
};
inline bool operator!(errc ec) { return ec == errc::ok; }
inline std::string_view make_error_message(errc ec) {
Expand Down
8 changes: 4 additions & 4 deletions include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ struct coro_rpc_protocol {
struct resp_header {
uint8_t magic; //!< magic number
uint8_t version; //!< rpc protocol version
uint8_t err_code; //!< rpc error type
uint8_t msg_type; //!< message type
uint16_t err_code; //!< rpc error type
uint32_t seq_num; //!< sequence number
uint32_t length; //!< length of RPC body
uint32_t attach_length; //!< reserved field
uint8_t msg_type; //!< message type
};

using supported_serialize_protocols = std::variant<struct_pack_protocol>;
Expand Down Expand Up @@ -151,7 +151,7 @@ struct coro_rpc_protocol {
auto& resp_head = *(resp_header*)header_buf.data();
resp_head.magic = magic_number;
resp_head.seq_num = req_header.seq_num;
resp_head.err_code = static_cast<uint8_t>(rpc_err_code);
resp_head.err_code = static_cast<uint16_t>(rpc_err_code);
resp_head.attach_length = attachment_len;
if (rpc_err_code != coro_rpc::errc{})
AS_UNLIKELY {
Expand Down Expand Up @@ -179,7 +179,7 @@ struct coro_rpc_protocol {
static_assert(REQ_HEAD_LEN == 20);

static constexpr auto RESP_HEAD_LEN = sizeof(resp_header{});
static_assert(RESP_HEAD_LEN == 16);
static_assert(RESP_HEAD_LEN == 20);
};
} // namespace protocol
template <typename return_msg_type>
Expand Down

0 comments on commit 746b598

Please sign in to comment.