/Users/deen/code/yugabyte-db/src/yb/tserver/tserver_error.h
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | // |
14 | | // |
15 | | |
16 | | #ifndef YB_TSERVER_TSERVER_ERROR_H |
17 | | #define YB_TSERVER_TSERVER_ERROR_H |
18 | | |
19 | | #include "yb/tserver/tserver_types.pb.h" |
20 | | |
21 | | #include "yb/util/monotime.h" |
22 | | #include "yb/util/status_ec.h" |
23 | | |
24 | | namespace yb { |
25 | | namespace tserver { |
26 | | |
27 | | struct TabletServerErrorTag : IntegralErrorTag<TabletServerErrorPB::Code> { |
28 | | // This category id is part of the wire protocol and should not be changed once released. |
29 | | static constexpr uint8_t kCategory = 5; |
30 | | |
31 | | typedef TabletServerErrorPB::Code Code; |
32 | | |
33 | 4.02k | static const std::string& ToMessage(Code code) { |
34 | 4.02k | return TabletServerErrorPB::Code_Name(code); |
35 | 4.02k | } |
36 | | }; |
37 | | |
38 | | typedef StatusErrorCodeImpl<TabletServerErrorTag> TabletServerError; |
39 | | |
40 | | class MonoDeltaTraits { |
41 | | public: |
42 | | typedef MonoDelta ValueType; |
43 | | typedef int64_t RepresentationType; |
44 | | |
45 | 0 | static MonoDelta FromRepresentation(RepresentationType source) { |
46 | 0 | return MonoDelta::FromNanoseconds(source); |
47 | 0 | } |
48 | | |
49 | 0 | static RepresentationType ToRepresentation(MonoDelta value) { |
50 | 0 | return value.ToNanoseconds(); |
51 | 0 | } |
52 | | |
53 | 0 | static std::string ToString(MonoDelta value) { |
54 | 0 | return value.ToString(); |
55 | 0 | } |
56 | | }; |
57 | | |
58 | | struct TabletServerDelayTag : IntegralBackedErrorTag<MonoDeltaTraits> { |
59 | | // This category id is part of the wire protocol and should not be changed once released. |
60 | | static constexpr uint8_t kCategory = 8; |
61 | | |
62 | 0 | static std::string ToMessage(MonoDelta value) { |
63 | 0 | return value.ToString(); |
64 | 0 | } |
65 | | }; |
66 | | |
67 | | typedef StatusErrorCodeImpl<TabletServerDelayTag> TabletServerDelay; |
68 | | |
69 | | } // namespace tserver |
70 | | } // namespace yb |
71 | | |
72 | | #endif // YB_TSERVER_TSERVER_ERROR_H |