Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SettingsProvider.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2023, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "data/cassandra/Types.hpp"
23#include "data/cassandra/impl/Cluster.hpp"
24#include "util/newconfig/ObjectView.hpp"
25
26#include <cstdint>
27#include <optional>
28#include <string>
29
30namespace data::cassandra {
31
37
38 std::string keyspace_;
39 std::optional<std::string> tablePrefix_;
40 uint16_t replicationFactor_;
41 Settings settings_;
42
43public:
49 explicit SettingsProvider(util::config::ObjectView const& cfg);
50
54 [[nodiscard]] Settings
55 getSettings() const;
56
60 [[nodiscard]] std::string
62 {
63 return keyspace_;
64 }
65
69 [[nodiscard]] std::optional<std::string>
71 {
72 return tablePrefix_;
73 }
74
78 [[nodiscard]] uint16_t
80 {
81 return replicationFactor_;
82 }
83
84private:
85 [[nodiscard]] std::optional<std::string>
86 parseOptionalCertificate() const;
87
88 [[nodiscard]] Settings
89 parseSettings() const;
90};
91
92} // namespace data::cassandra
Provides settings for BasicCassandraBackend.
Definition SettingsProvider.hpp:35
Settings getSettings() const
Definition SettingsProvider.cpp:52
std::optional< std::string > getTablePrefix() const
Definition SettingsProvider.hpp:70
std::string getKeyspace() const
Definition SettingsProvider.hpp:61
uint16_t getReplicationFactor() const
Definition SettingsProvider.hpp:79
SettingsProvider(util::config::ObjectView const &cfg)
Create a settings provider from the specified config.
Definition SettingsProvider.cpp:42
Provides a view into a subset of configuration data defined by a prefix.
Definition ObjectView.hpp:40
This namespace implements a wrapper for the Cassandra C++ driver.
Definition Concepts.hpp:37
Bundles all cassandra settings in one place.
Definition Cluster.hpp:43