const_vars.h 654 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <cstdint>
  3. namespace rest_rpc {
  4. enum class result_code : std::int16_t {
  5. OK = 0,
  6. FAIL = 1,
  7. };
  8. enum class error_code {
  9. OK,
  10. UNKNOWN,
  11. FAIL,
  12. TIMEOUT,
  13. CANCEL,
  14. BADCONNECTION,
  15. };
  16. enum class request_type : uint8_t {
  17. req_res,
  18. sub_pub
  19. };
  20. struct message_type {
  21. std::uint64_t req_id;
  22. request_type req_type;
  23. std::shared_ptr<std::string> content;
  24. };
  25. #pragma pack (1)
  26. struct rpc_header {
  27. uint32_t body_len;
  28. uint64_t req_id;
  29. request_type req_type;
  30. };
  31. #pragma pack ()
  32. static const size_t MAX_BUF_LEN = 1048576 * 10;
  33. static const size_t HEAD_LEN = 13;
  34. static const size_t INIT_BUF_SIZE = 2 * 1024;
  35. }