hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
pg_connection_init.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_PG_CONNECTION_INIT_HPP
7 #define IROHA_PG_CONNECTION_INIT_HPP
8 
9 #include <soci/soci.h>
10 
11 #include <soci/callbacks.h>
12 #include <soci/postgresql/soci-postgresql.h>
13 #include <boost/algorithm/string.hpp>
14 #include <boost/range/algorithm/replace_if.hpp>
15 
20 #include "common/result.hpp"
22 #include "logger/logger_fwd.hpp"
24 #include "main/startup_params.hpp"
25 
26 namespace iroha {
27  namespace ametsuchi {
28 
29  struct PoolWrapper;
30 
32  public:
34  StartupWsvDataPolicy startup_wsv_data_policy,
35  const PostgresOptions &options);
36 
39  const ReconnectionStrategyFactory &reconnection_strategy_factory,
40  const PostgresOptions &options,
41  const int pool_size,
42  logger::LoggerManagerTreePtr log_manager);
43 
47  static bool preparedTransactionsAvailable(soci::session &sql);
48 
50  soci::session &sql, const std::string &prepared_block_name);
51 
52  /*
53  * Drop working database.
54  * @return Error message if dropping has failed.
55  */
57  const PostgresOptions &options);
58 
63  static expected::Result<void, std::string> resetPeers(soci::session &sql);
64 
66  static void prepareTables(soci::session &session);
67 
73  const PostgresOptions &postgres_options);
74 
75  private:
91  template <typename RollbackFunction>
92  static expected::Result<void, std::string> initializeConnectionPool(
93  soci::connection_pool &connection_pool,
94  size_t pool_size,
95  RollbackFunction try_rollback,
96  FailoverCallbackHolder &callback_factory,
97  const ReconnectionStrategyFactory &reconnection_strategy_factory,
98  const std::string &pg_reconnection_options,
99  logger::LoggerManagerTreePtr log_manager);
100  };
101  } // namespace ametsuchi
102 } // namespace iroha
103 
104 #endif // IROHA_PG_CONNECTION_INIT_HPP
Definition: postgres_options.hpp:19
static bool preparedTransactionsAvailable(soci::session &sql)
Definition: pg_connection_init.cpp:206
static expected::Result< void, std::string > createSchema(const PostgresOptions &postgres_options)
Definition: pg_connection_init.cpp:449
Definition: reconnection_strategy.hpp:35
Definition: pg_connection_init.hpp:31
static expected::Result< std::shared_ptr< PoolWrapper >, std::string > prepareConnectionPool(const ReconnectionStrategyFactory &reconnection_strategy_factory, const PostgresOptions &options, const int pool_size, logger::LoggerManagerTreePtr log_manager)
Definition: pg_connection_init.cpp:153
Definition: failover_callback_holder.hpp:13
Definition: result_fwd.hpp:27
Definition: block_query.hpp:15
StartupWsvDataPolicy
Policy regarging possible existing WSV data at startup.
Definition: startup_params.hpp:11
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
static void prepareTables(soci::session &session)
Create tables in the given session. Left public for tests.
Definition: pg_connection_init.cpp:287
static iroha::expected::Result< void, std::string > rollbackPrepared(soci::session &sql, const std::string &prepared_block_name)
Definition: pg_connection_init.cpp:216
static expected::Result< void, std::string > dropWorkingDatabase(const PostgresOptions &options)
Definition: pg_connection_init.cpp:442
static expected::Result< void, std::string > prepareWorkingDatabase(StartupWsvDataPolicy startup_wsv_data_policy, const PostgresOptions &options)
Definition: pg_connection_init.cpp:133
static expected::Result< void, std::string > resetPeers(soci::session &sql)
Definition: pg_connection_init.cpp:466