22#include "data/BackendInterface.hpp"
23#include "data/CassandraBackend.hpp"
24#include "data/KeyspaceBackend.hpp"
25#include "data/LedgerCacheInterface.hpp"
26#include "data/cassandra/SettingsProvider.hpp"
27#include "util/config/ConfigDefinition.hpp"
28#include "util/log/Logger.hpp"
30#include <boost/algorithm/string.hpp>
31#include <boost/algorithm/string/predicate.hpp>
46inline std::shared_ptr<BackendInterface>
49 using namespace cassandra::impl;
51 LOG(log.
info()) <<
"Constructing BackendInterface";
53 auto const readOnly = config.
get<
bool>(
"read_only");
55 auto const type = config.
get<std::string>(
"database.type");
56 std::shared_ptr<BackendInterface> backend =
nullptr;
58 if (boost::iequals(type,
"cassandra")) {
59 auto const cfg = config.
getObject(
"database." + type);
60 if (providerFromString(cfg.getValueView(
"provider").asString()) == Provider::Keyspace) {
61 backend = std::make_shared<data::cassandra::KeyspaceBackend>(
65 backend = std::make_shared<data::cassandra::CassandraBackend>(
72 throw std::runtime_error(
"Invalid database type");
74 auto const rng = backend->hardFetchLedgerRangeNoThrow();
76 backend->setRange(rng->minSequence, rng->maxSequence);
78 LOG(log.
info()) <<
"Constructed BackendInterface Successfully";
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:38
Provides settings for BasicCassandraBackend.
Definition SettingsProvider.hpp:35
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:94
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:463
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:50
ObjectView getObject(std::string_view prefix, std::optional< std::size_t > idx=std::nullopt) const
Returns the ObjectView specified with the prefix.
Definition ConfigDefinition.cpp:63
T get(std::string_view fullKey) const
Returns the specified value of given string if value exists.
Definition ConfigDefinition.hpp:104
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
std::shared_ptr< BackendInterface > makeBackend(util::config::ClioConfigDefinition const &config, data::LedgerCacheInterface &cache)
A factory function that creates the backend based on a config.
Definition BackendFactory.hpp:47