hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
server_runner.hpp
Go to the documentation of this file.
1 
6 #ifndef MAIN_SERVER_RUNNER_HPP
7 #define MAIN_SERVER_RUNNER_HPP
8 
9 #include <grpc++/grpc++.h>
10 #include <grpc++/impl/codegen/service_type.h>
11 #include "common/result.hpp"
12 #include "logger/logger_fwd.hpp"
13 
17 class ServerRunner {
18  public:
25  explicit ServerRunner(const std::string &address,
27  bool reuse = true);
28 
34  ServerRunner &append(std::shared_ptr<grpc::Service> service);
35 
40  iroha::expected::Result<int, std::string> run();
41 
45  void waitForServersReady();
46 
50  void shutdown();
51 
55  void shutdown(const std::chrono::system_clock::time_point &deadline);
56 
57  private:
58  logger::LoggerPtr log_;
59 
60  std::unique_ptr<grpc::Server> serverInstance_;
61  std::mutex waitForServer_;
62  std::condition_variable serverInstanceCV_;
63 
64  std::string serverAddress_;
65  bool reuse_;
66  std::vector<std::shared_ptr<grpc::Service>> services_;
67 };
68 
69 #endif // MAIN_SERVER_RUNNER_HPP
void waitForServersReady()
Definition: server_runner.cpp:53
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: server_runner.hpp:17
ServerRunner & append(std::shared_ptr< grpc::Service > service)
Definition: server_runner.cpp:18
ServerRunner(const std::string &address, logger::LoggerPtr log, bool reuse=true)
Definition: server_runner.cpp:13
iroha::expected::Result< int, std::string > run()
Definition: server_runner.cpp:23
void shutdown()
Definition: server_runner.cpp:60