hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
generic_client_factory.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_GENERIC_CLIENT_FACTORY_HPP
7 #define IROHA_GENERIC_CLIENT_FACTORY_HPP
8 
9 #include <memory>
10 
11 #include "common/result.hpp"
13 
14 namespace iroha {
15  namespace network {
16 
18  public:
19  GenericClientFactory(std::unique_ptr<ChannelProvider> channel_provider);
20 
28  template <typename Service>
29  iroha::expected::Result<std::unique_ptr<typename Service::StubInterface>,
30  std::string>
32  using iroha::expected::operator|;
33  return channel_provider_->getChannel(Service::service_full_name(), peer)
34  | [](auto &&channel) { return Service::NewStub(channel); };
35  }
36 
37  private:
38  std::unique_ptr<ChannelProvider> channel_provider_;
39  };
40 
41  } // namespace network
42 } // namespace iroha
43 
44 #endif
Definition: peer.hpp:20
Definition: block_query.hpp:14
iroha::expected::Result< std::unique_ptr< typename Service::StubInterface >, std::string > createClient(const shared_model::interface::Peer &peer) const
Definition: generic_client_factory.hpp:31
Definition: generic_client_factory.hpp:17
GenericClientFactory(std::unique_ptr< ChannelProvider > channel_provider)
Definition: generic_client_factory.cpp:10