YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/client/transaction_rpc.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_CLIENT_TRANSACTION_RPC_H
17
#define YB_CLIENT_TRANSACTION_RPC_H
18
19
#include <functional>
20
21
#include <boost/preprocessor/empty.hpp>
22
#include <boost/preprocessor/seq/for_each.hpp>
23
24
#include "yb/client/client_fwd.h"
25
#include "yb/rpc/rpc_fwd.h"
26
27
#include "yb/tserver/tserver_fwd.h"
28
29
#include "yb/util/monotime.h"
30
#include "yb/util/status_fwd.h"
31
32
namespace yb {
33
34
class HybridTime;
35
36
#define TRANSACTION_RPCS \
37
    ((UpdateTransaction, WITH_REQUEST)) \
38
    ((GetTransactionStatus, WITHOUT_REQUEST)) \
39
    ((GetTransactionStatusAtParticipant, WITHOUT_REQUEST)) \
40
    ((AbortTransaction, WITHOUT_REQUEST))
41
42
#define TRANSACTION_RPC_NAME(entry) BOOST_PP_TUPLE_ELEM(2, 0, entry)
43
44
namespace client {
45
46
// Common arguments for all functions from this header.
47
// deadline - operation deadline, i.e. timeout.
48
// tablet - handle of status tablet for this transaction, could be null when unknown.
49
// client - YBClient that should be used to send this request.
50
51
#define TRANSACTION_RPC_CALLBACK(rpc) BOOST_PP_CAT(TRANSACTION_RPC_NAME(rpc), Callback)
52
#define TRANSACTION_RPC_REQUEST_PB(rpc) tserver::BOOST_PP_CAT(TRANSACTION_RPC_NAME(rpc), RequestPB)
53
#define TRANSACTION_RPC_RESPONSE_PB(rpc) \
54
    tserver::BOOST_PP_CAT(TRANSACTION_RPC_NAME(rpc), ResponsePB)
55
56
#define TRANSACTION_RPC_OPTIONAL_REQUEST_HELPER_WITH_REQUEST(entry) \
57
  const TRANSACTION_RPC_REQUEST_PB(entry)&,
58
59
#define TRANSACTION_RPC_OPTIONAL_REQUEST_HELPER_WITHOUT_REQUEST(entry)
60
61
#define TRANSACTION_RPC_OPTIONAL_REQUEST_PB(entry) \
62
  BOOST_PP_CAT(TRANSACTION_RPC_OPTIONAL_REQUEST_HELPER_, BOOST_PP_TUPLE_ELEM(2, 1, entry))(entry)
63
64
#define TRANSACTION_RPC_SEMICOLON(rpc) ; // NOLINT
65
66
#define TRANSACTION_RPC_FUNCTION(i, data, entry) \
67
  using TRANSACTION_RPC_CALLBACK(entry) = std::function<void( \
68
      const Status&,                             \
69
      TRANSACTION_RPC_OPTIONAL_REQUEST_PB(entry) \
70
      const TRANSACTION_RPC_RESPONSE_PB(entry)&)>; \
71
  MUST_USE_RESULT rpc::RpcCommandPtr TRANSACTION_RPC_NAME(entry)( \
72
      CoarseTimePoint deadline, \
73
      internal::RemoteTablet* tablet, \
74
      YBClient* client, \
75
      TRANSACTION_RPC_REQUEST_PB(entry)* req, \
76
      TRANSACTION_RPC_CALLBACK(entry) callback) data(entry) \
77
78
BOOST_PP_SEQ_FOR_EACH(TRANSACTION_RPC_FUNCTION, TRANSACTION_RPC_SEMICOLON, TRANSACTION_RPCS)
79
80
template <class Response, class T>
81
931k
void UpdateClock(const Response& resp, T* t) {
82
931k
  if (resp.has_propagated_hybrid_time()) {
83
928k
    t->UpdateClock(HybridTime(resp.propagated_hybrid_time()));
84
928k
  }
85
931k
}
_ZN2yb6client11UpdateClockINS_7tserver27UpdateTransactionResponsePBENS_6tablet29TransactionCoordinatorContextEEEvRKT_PT0_
Line
Count
Source
81
246k
void UpdateClock(const Response& resp, T* t) {
82
246k
  if (resp.has_propagated_hybrid_time()) {
83
246k
    t->UpdateClock(HybridTime(resp.propagated_hybrid_time()));
84
246k
  }
85
246k
}
Unexecuted instantiation: _ZN2yb6client11UpdateClockINS_7tserver43GetTransactionStatusAtParticipantResponsePBENS_6tablet29TransactionCoordinatorContextEEEvRKT_PT0_
_ZN2yb6client11UpdateClockINS_7tserver27UpdateTransactionResponsePBENS_6tablet29TransactionParticipantContextEEEvRKT_PT0_
Line
Count
Source
81
246k
void UpdateClock(const Response& resp, T* t) {
82
246k
  if (resp.has_propagated_hybrid_time()) {
83
246k
    t->UpdateClock(HybridTime(resp.propagated_hybrid_time()));
84
246k
  }
85
246k
}
_ZN2yb6client11UpdateClockINS_7tserver27UpdateTransactionResponsePBENS0_18TransactionManagerEEEvRKT_PT0_
Line
Count
Source
81
438k
void UpdateClock(const Response& resp, T* t) {
82
438k
  if (resp.has_propagated_hybrid_time()) {
83
436k
    t->UpdateClock(HybridTime(resp.propagated_hybrid_time()));
84
436k
  }
85
438k
}
86
87
} // namespace client
88
} // namespace yb
89
90
#endif // YB_CLIENT_TRANSACTION_RPC_H