src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
0 / 2
0.0%
Branches:
-
-%
Functions:
0 / 1
0.0%

ps/rdma/rdma_status.h
Line Branch Exec Source
1 #pragma once
2
3 #include <cstdint>
4 #include <stdexcept>
5 #include <string>
6
7 namespace petps {
8
9 // Client-visible failure raised when a shard is judged unreachable by the
10 // slow-path health verdict, or when its lane was retired after losing a
11 // completion. Kept distinct from the server-returned RpcStatus codes and from
12 // a plain wait timeout so callers can fail fast without retrying blindly.
13 class ShardUnreachableError : public std::runtime_error {
14 public:
15 ✗ explicit ShardUnreachableError(const std::string& message)
16 ✗ : std::runtime_error(message) {}
17 };
18
19 enum class RpcStatus : std::int32_t {
20 kPending = 123456789,
21 kOk = 0,
22 kInvalidPayload = -1,
23 kWrongShard = -2,
24 kBatchTooLarge = -3,
25 kValueSizeMismatch = -4,
26 kServerDraining = -5,
27 kInternalError = -6,
28 };
29
30 inline const char* RpcStatusToString(RpcStatus status) {
31 switch (status) {
32 case RpcStatus::kPending:
33 return "pending";
34 case RpcStatus::kOk:
35 return "ok";
36 case RpcStatus::kInvalidPayload:
37 return "invalid_payload";
38 case RpcStatus::kWrongShard:
39 return "wrong_shard";
40 case RpcStatus::kBatchTooLarge:
41 return "batch_too_large";
42 case RpcStatus::kValueSizeMismatch:
43 return "value_size_mismatch";
44 case RpcStatus::kServerDraining:
45 return "server_draining";
46 case RpcStatus::kInternalError:
47 return "internal_error";
48 }
49 return "unknown";
50 }
51
52 } // namespace petps
53