Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #ifndef IROHA_GRPC_CHANNEL_BUILDER_HPP
7 : #define IROHA_GRPC_CHANNEL_BUILDER_HPP
8 :
9 : #include <grpc++/grpc++.h>
10 :
11 : namespace iroha {
12 : namespace network {
13 :
14 : /**
15 : * Creates client which is capable of sending and receiving
16 : * messages of INT_MAX bytes size
17 : * @tparam T type for gRPC stub, e.g. proto::Yac
18 : * @param address ip address for connection, ipv4:port
19 : * @return gRPC stub of parametrized type
20 : */
21 : template <typename T>
22 : auto createClient(const grpc::string& address) {
23 : // in order to bypass built-in limitation of gRPC message size
24 14267 : grpc::ChannelArguments args;
25 14267 : args.SetMaxSendMessageSize(INT_MAX);
26 14267 : args.SetMaxReceiveMessageSize(INT_MAX);
27 :
28 14267 : return
29 14267 : T::NewStub(grpc::CreateCustomChannel(
30 14267 : address, grpc::InsecureChannelCredentials(), args));
31 14267 : }
32 : } // namespace network
33 : } // namespace iroha
34 :
35 : #endif // IROHA_GRPC_CHANNEL_BUILDER_HPP
|