hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
failover_callback.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_FAILOVER_CALLBACK_HPP
7 #define IROHA_FAILOVER_CALLBACK_HPP
8 
9 #include <memory>
10 
11 #include <soci/soci.h>
12 
13 #include <soci/callbacks.h>
14 
16 #include "logger/logger_fwd.hpp"
17 
18 namespace iroha {
19  namespace ametsuchi {
25  class FailoverCallback final : public soci::failover_callback {
26  public:
27  using InitFunctionType = std::function<void(soci::session &)>;
29  soci::session &connection,
30  InitFunctionType init,
31  std::string connection_options,
32  std::unique_ptr<ReconnectionStrategy> reconnection_strategy,
33  logger::LoggerPtr log);
34 
35  FailoverCallback(const FailoverCallback &) = delete;
36  FailoverCallback &operator=(const FailoverCallback &) = delete;
37 
38  void started() override;
39 
40  void finished(soci::session &) override;
41 
42  void failed(bool &should_reconnect, std::string &) override;
43 
44  void aborted() override;
45 
46  private:
47  bool reconnectionLoop();
48 
49  soci::session &connection_;
50  InitFunctionType init_session_;
51  const std::string connection_options_;
52  std::unique_ptr<ReconnectionStrategy> reconnection_strategy_;
53  logger::LoggerPtr log_;
54  };
55  } // namespace ametsuchi
56 } // namespace iroha
57 
58 #endif // IROHA_FAILOVER_CALLBACK_HPP
FailoverCallback(soci::session &connection, InitFunctionType init, std::string connection_options, std::unique_ptr< ReconnectionStrategy > reconnection_strategy, logger::LoggerPtr log)
Definition: failover_callback.cpp:16
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:14
void finished(soci::session &) override
Definition: failover_callback.cpp:33
void started() override
Definition: failover_callback.cpp:28
Definition: failover_callback.hpp:25
void aborted() override
Definition: failover_callback.cpp:46
void failed(bool &should_reconnect, std::string &) override
Definition: failover_callback.cpp:35
std::function< void(soci::session &)> InitFunctionType
Definition: failover_callback.hpp:27
FailoverCallback & operator=(const FailoverCallback &)=delete