/Users/deen/code/yugabyte-db/src/yb/rpc/remote_method.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | // |
18 | | // The following only applies to changes made to this file as part of YugaByte development. |
19 | | // |
20 | | // Portions Copyright (c) YugaByte, Inc. |
21 | | // |
22 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
23 | | // in compliance with the License. You may obtain a copy of the License at |
24 | | // |
25 | | // http://www.apache.org/licenses/LICENSE-2.0 |
26 | | // |
27 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
28 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
29 | | // or implied. See the License for the specific language governing permissions and limitations |
30 | | // under the License. |
31 | | // |
32 | | |
33 | | #include "yb/rpc/remote_method.h" |
34 | | |
35 | | #include "yb/rpc/rpc_header.pb.h" |
36 | | |
37 | | #include "yb/util/format.h" |
38 | | #include "yb/util/scope_exit.h" |
39 | | |
40 | | namespace yb { |
41 | | namespace rpc { |
42 | | |
43 | | RemoteMethod::RemoteMethod(std::string service_name, |
44 | | std::string method_name) |
45 | 1.60M | : service_name_(std::move(service_name)), method_name_(std::move(method_name)) { |
46 | 1.60M | RequestHeader pb; |
47 | 1.60M | pb.mutable_remote_method()->set_allocated_service_name(&service_name_); |
48 | 1.60M | pb.mutable_remote_method()->set_allocated_method_name(&method_name_); |
49 | 1.60M | auto se = ScopeExit([&pb] { |
50 | 1.60M | pb.mutable_remote_method()->release_method_name(); |
51 | 1.60M | pb.mutable_remote_method()->release_service_name(); |
52 | 1.60M | }); |
53 | 1.60M | serialized_ = pb.SerializeAsString(); |
54 | 1.60M | } |
55 | | |
56 | 1 | void RemoteMethod::ToPB(RemoteMethodPB* pb) const { |
57 | 1 | pb->set_service_name(service_name_); |
58 | 1 | pb->set_method_name(method_name_); |
59 | 1 | } |
60 | | |
61 | 0 | size_t RemoteMethod::DynamicMemoryUsage() const { |
62 | 0 | return service_name_.size() + method_name_.size() + serialized_.size(); |
63 | 0 | } |
64 | | |
65 | 3.40M | string RemoteMethod::ToString() const { |
66 | 3.40M | return Format("$0.$1", service_name(), method_name()); |
67 | 3.40M | } |
68 | | |
69 | | } // namespace rpc |
70 | | } // namespace yb |