/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 | 1.59M | void UpdateClock(const Response& resp, T* t) { |
82 | 1.59M | if (resp.has_propagated_hybrid_time()) { |
83 | 1.59M | t->UpdateClock(HybridTime(resp.propagated_hybrid_time())); |
84 | 1.59M | } |
85 | 1.59M | } void yb::client::UpdateClock<yb::tserver::UpdateTransactionResponsePB, yb::tablet::TransactionCoordinatorContext>(yb::tserver::UpdateTransactionResponsePB const&, yb::tablet::TransactionCoordinatorContext*) Line | Count | Source | 81 | 436k | void UpdateClock(const Response& resp, T* t) { | 82 | 436k | if (resp.has_propagated_hybrid_time()) { | 83 | 436k | t->UpdateClock(HybridTime(resp.propagated_hybrid_time())); | 84 | 436k | } | 85 | 436k | } |
Unexecuted instantiation: void yb::client::UpdateClock<yb::tserver::GetTransactionStatusAtParticipantResponsePB, yb::tablet::TransactionCoordinatorContext>(yb::tserver::GetTransactionStatusAtParticipantResponsePB const&, yb::tablet::TransactionCoordinatorContext*) void yb::client::UpdateClock<yb::tserver::UpdateTransactionResponsePB, yb::tablet::TransactionParticipantContext>(yb::tserver::UpdateTransactionResponsePB const&, yb::tablet::TransactionParticipantContext*) Line | Count | Source | 81 | 436k | void UpdateClock(const Response& resp, T* t) { | 82 | 436k | if (resp.has_propagated_hybrid_time()) { | 83 | 436k | t->UpdateClock(HybridTime(resp.propagated_hybrid_time())); | 84 | 436k | } | 85 | 436k | } |
void yb::client::UpdateClock<yb::tserver::UpdateTransactionResponsePB, yb::client::TransactionManager>(yb::tserver::UpdateTransactionResponsePB const&, yb::client::TransactionManager*) Line | Count | Source | 81 | 726k | void UpdateClock(const Response& resp, T* t) { | 82 | 726k | if (resp.has_propagated_hybrid_time()) { | 83 | 724k | t->UpdateClock(HybridTime(resp.propagated_hybrid_time())); | 84 | 724k | } | 85 | 726k | } |
|
86 | | |
87 | | } // namespace client |
88 | | } // namespace yb |
89 | | |
90 | | #endif // YB_CLIENT_TRANSACTION_RPC_H |