support for read replicas with postgres

This commit is contained in:
CJ Cobb
2021-04-28 19:02:44 +00:00
parent 0cfce33724
commit 5ebc515978
6 changed files with 8 additions and 7 deletions

View File

@@ -132,7 +132,7 @@ public:
// Open the database. Set up all of the necessary objects and
// datastructures. After this call completes, the database is ready for use.
virtual void
open() = 0;
open(bool readOnly) = 0;
// Close the database, releasing any resources
virtual void

View File

@@ -273,7 +273,7 @@ CassandraBackend::doOnlineDelete(uint32_t minLedgerToKeep) const
}
void
CassandraBackend::open()
CassandraBackend::open(bool readOnly)
{
std::cout << config_ << std::endl;
auto getString = [this](std::string const& field) -> std::string {

View File

@@ -665,7 +665,7 @@ public:
// Create the table if it doesn't exist already
// @param createIfMissing ignored
void
open() override;
open(bool readOnly) override;
// Close the connection to the database
void

View File

@@ -625,9 +625,10 @@ PostgresBackend::fetchAccountTransactions(
} // namespace Backend
void
PostgresBackend::open()
PostgresBackend::open(bool readOnly)
{
initSchema(pgPool_);
if (!readOnly)
initSchema(pgPool_);
}
void

View File

@@ -101,7 +101,7 @@ public:
std::vector<AccountTransactionsData>&& data) const override;
void
open() override;
open(bool readOnly) override;
void
close() override;

View File

@@ -711,7 +711,6 @@ ReportingETL::ReportingETL(
networkValidatedLedgers_,
ioc)
{
flatMapBackend_->open();
if (config.contains("start_sequence"))
startSequence_ = config.at("start_sequence").as_int64();
if (config.contains("finish_sequence"))
@@ -724,5 +723,6 @@ ReportingETL::ReportingETL(
extractorThreads_ = config.at("extractor_threads").as_int64();
if (config.contains("txn_threshold"))
txnThreshold_ = config.at("txn_threshold").as_int64();
flatMapBackend_->open(readOnly_);
}