YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tserver/tserver_error.h
Line
Count
Source
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
2.01k
  static const std::string& ToMessage(Code code) {
34
2.01k
    return TabletServerErrorPB::Code_Name(code);
35
2.01k
  }
36
};
37
38
typedef StatusErrorCodeImpl<TabletServerErrorTag> TabletServerError;
39
40
class MonoDeltaTraits {
41
 public:
42
  typedef MonoDelta ValueType;
43
  typedef int64_t RepresentationType;
44
45
18
  static MonoDelta FromRepresentation(RepresentationType source) {
46
18
    return MonoDelta::FromNanoseconds(source);
47
18
  }
48
49
6
  static RepresentationType ToRepresentation(MonoDelta value) {
50
6
    return value.ToNanoseconds();
51
6
  }
52
53
6
  static std::string ToString(MonoDelta value) {
54
6
    return value.ToString();
55
6
  }
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
6
  static std::string ToMessage(MonoDelta value) {
63
6
    return value.ToString();
64
6
  }
65
};
66
67
typedef StatusErrorCodeImpl<TabletServerDelayTag> TabletServerDelay;
68
69
} // namespace tserver
70
} // namespace yb
71
72
#endif // YB_TSERVER_TSERVER_ERROR_H