3#include "data/BackendInterface.hpp"
4#include "data/CassandraBackend.hpp"
5#include "data/KeyspaceBackend.hpp"
6#include "data/LedgerCacheInterface.hpp"
7#include "data/cassandra/SettingsProvider.hpp"
8#include "util/config/ConfigDefinition.hpp"
9#include "util/log/Logger.hpp"
11#include <boost/algorithm/string.hpp>
12#include <boost/algorithm/string/predicate.hpp>
27inline std::shared_ptr<BackendInterface>
30 using namespace cassandra::impl;
32 LOG(log.
info()) <<
"Constructing BackendInterface";
34 auto const readOnly = config.
get<
bool>(
"read_only");
36 auto const type = config.
get<std::string>(
"database.type");
37 std::shared_ptr<BackendInterface> backend =
nullptr;
39 if (boost::iequals(type,
"cassandra")) {
40 auto const cfg = config.
getObject(
"database." + type);
41 if (providerFromString(cfg.getValueView(
"provider").asString()) == Provider::Keyspace) {
42 backend = std::make_shared<data::cassandra::KeyspaceBackend>(
46 backend = std::make_shared<data::cassandra::CassandraBackend>(
53 throw std::runtime_error(
"Invalid database type");
55 auto const rng = backend->hardFetchLedgerRangeNoThrow();
57 backend->setRange(rng->minSequence, rng->maxSequence);
59 LOG(log.
info()) <<
"Constructed BackendInterface Successfully";
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:21
Provides settings for BasicCassandraBackend.
Definition SettingsProvider.hpp:16
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:77
Pump info(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::NFO severity.
Definition Logger.cpp:488
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:31
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:44
T get(std::string_view fullKey) const
Returns the specified value of given string if value exists.
Definition ConfigDefinition.hpp:85
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56
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:28