22#include "util/Assert.hpp"
23#include "util/newconfig/ConfigDefinition.hpp"
24#include "util/newconfig/Error.hpp"
38namespace util::config {
50 std::string_view value;
66 [[nodiscard]]
static constexpr std::string_view
67 get(std::string_view key)
69 auto const itr = std::ranges::find_if(kCONFIG_DESCRIPTION, [&](
auto const& v) {
return v.key == key; });
70 ASSERT(itr != kCONFIG_DESCRIPTION.end(),
"Key {} doesn't exist in config", key);
80 [[nodiscard]]
static std::expected<void, Error>
83 namespace fs = std::filesystem;
86 auto const dir = path.parent_path();
87 if (!dir.empty() && !fs::exists(dir)) {
88 return std::unexpected<Error>{
89 fmt::format(
"Error: Directory '{}' does not exist or provided path is invalid", dir.string())
93 std::ofstream file(path.string());
94 if (!file.is_open()) {
95 return std::unexpected{fmt::format(
"Failed to create file '{}': {}", path.string(), std::strerror(errno))};
101 std::cout <<
"Markdown file generated successfully: " << path <<
"\n";
113 file <<
"# Clio Config Description\n";
114 file <<
"This file lists all Clio Configuration definitions in detail.\n\n";
115 file <<
"## Configuration Details\n\n";
117 for (
auto const& [key, val] : kCONFIG_DESCRIPTION) {
118 file <<
"### Key: " << key <<
"\n";
122 if (key.contains(
"[]")) {
123 file << gClioConfig.asArray(key);
125 file << gClioConfig.getValueView(key);
127 file <<
" - **Description**: " << val <<
"\n";
133 static constexpr auto kCONFIG_DESCRIPTION = std::array{
134 KV{.key =
"database.type",
135 .value =
"Type of database to use. We currently support Cassandra and Scylladb. We default to Scylladb."},
136 KV{.key =
"database.cassandra.contact_points",
137 .value =
"A list of IP addresses or hostnames of the initial nodes (Cassandra/Scylladb cluster nodes) that "
138 "the client will connect to when establishing a connection with the database. If you're running "
139 "locally, it should be 'localhost' or 127.0.0.1"},
140 KV{.key =
"database.cassandra.secure_connect_bundle",
141 .value =
"Configuration file that contains the necessary security credentials and connection details for "
143 "connecting to a Cassandra database cluster."},
144 KV{.key =
"database.cassandra.port", .value =
"Port number to connect to the database."},
145 KV{.key =
"database.cassandra.keyspace", .value =
"Keyspace to use for the database."},
146 KV{.key =
"database.cassandra.replication_factor",
147 .value =
"Number of replicated nodes for Scylladb. Visit this link for more details : "
148 "https://university.scylladb.com/courses/scylla-essentials-overview/lessons/high-availability/"
149 "topic/fault-tolerance-replication-factor/ "},
150 KV{.key =
"database.cassandra.table_prefix", .value =
"Prefix for Database table names."},
151 KV{.key =
"database.cassandra.max_write_requests_outstanding",
152 .value =
"Maximum number of outstanding write requests. Write requests are api calls that write to database "
154 KV{.key =
"database.cassandra.max_read_requests_outstanding",
155 .value =
"Maximum number of outstanding read requests, which reads from database"},
156 KV{.key =
"database.cassandra.threads", .value =
"Number of threads that will be used for database operations."
158 KV{.key =
"database.cassandra.core_connections_per_host",
159 .value =
"Number of core connections per host for Cassandra."},
160 KV{.key =
"database.cassandra.queue_size_io", .value =
"Queue size for I/O operations in Cassandra."},
161 KV{.key =
"database.cassandra.write_batch_size", .value =
"Batch size for write operations in Cassandra."},
162 KV{.key =
"database.cassandra.connect_timeout",
163 .value =
"The maximum amount of time in seconds the system will wait for a connection to be successfully "
165 "with the database."},
166 KV{.key =
"database.cassandra.request_timeout",
168 "The maximum amount of time in seconds the system will wait for a request to be fetched from database."},
169 KV{.key =
"database.cassandra.username", .value =
"The username used for authenticating with the database."},
170 KV{.key =
"database.cassandra.password", .value =
"The password used for authenticating with the database."},
171 KV{.key =
"database.cassandra.certfile",
172 .value =
"The path to the SSL/TLS certificate file used to establish a secure connection between the client "
174 "Cassandra database."},
175 KV{.key =
"allow_no_etl", .value =
"If True, no ETL nodes will run with Clio."},
176 KV{.key =
"etl_sources.[].ip", .value =
"IP address of the ETL source."},
177 KV{.key =
"etl_sources.[].ws_port", .value =
"WebSocket port of the ETL source."},
178 KV{.key =
"etl_sources.[].grpc_port", .value =
"gRPC port of the ETL source."},
179 KV{.key =
"forwarding.cache_timeout",
180 .value =
"Timeout duration for the forwarding cache used in Rippled communication."},
181 KV{.key =
"forwarding.request_timeout",
182 .value =
"Timeout duration for the forwarding request used in Rippled communication."},
183 KV{.key =
"rpc.cache_timeout", .value =
"Timeout duration for RPC requests."},
184 KV{.key =
"num_markers",
185 .value =
"The number of markers is the number of coroutines to download the initial ledger"},
186 KV{.key =
"dos_guard.whitelist.[]", .value =
"List of IP addresses to whitelist for DOS protection."},
187 KV{.key =
"dos_guard.max_fetches", .value =
"Maximum number of fetch operations allowed by DOS guard."},
188 KV{.key =
"dos_guard.max_connections", .value =
"Maximum number of concurrent connections allowed by DOS guard."
190 KV{.key =
"dos_guard.max_requests", .value =
"Maximum number of requests allowed by DOS guard."},
191 KV{.key =
"dos_guard.sweep_interval", .value =
"Interval in seconds for DOS guard to sweep/clear its state."},
192 KV{.key =
"workers", .value =
"Number of threads to process RPC requests."},
193 KV{.key =
"server.ip", .value =
"IP address of the Clio HTTP server."},
194 KV{.key =
"server.port", .value =
"Port number of the Clio HTTP server."},
195 KV{.key =
"server.max_queue_size",
196 .value =
"Maximum size of the server's request queue. Value of 0 is no limit."},
197 KV{.key =
"server.local_admin",
198 .value =
"Indicates if the server should run with admin privileges. Only one of local_admin or "
199 "admin_password can be set."},
200 KV{.key =
"server.admin_password",
201 .value =
"Password for Clio admin-only APIs. Only one of local_admin or admin_password can be set."},
202 KV{.key =
"server.processing_policy",
203 .value = R
"(Could be "sequent" or "parallel". For the sequent policy, requests from a single client
204 connection are processed one by one, with the next request read only after the previous one is processed. For the parallel policy, Clio will accept
205 all requests and process them in parallel, sending a reply for each request as soon as it is ready.)"},
206 KV{.key = "server.parallel_requests_limit",
208 R
"(Optional parameter, used only if processing_strategy `parallel`. It limits the number of requests for a single client connection that are processed in parallel. If not specified, the limit is infinite.)"
210 KV{.key = "server.ws_max_sending_queue_size", .value =
"Maximum size of the websocket sending queue."},
211 KV{.key =
"prometheus.enabled", .value =
"Enable or disable Prometheus metrics."},
212 KV{.key =
"prometheus.compress_reply", .value =
"Enable or disable compression of Prometheus responses."},
213 KV{.key =
"io_threads", .value =
"Number of I/O threads. Value cannot be less than 1"},
214 KV{.key =
"subscription_workers",
215 .value =
"The number of worker threads or processes that are responsible for managing and processing "
216 "subscription-based tasks from rippled"},
217 KV{.key =
"graceful_period", .value =
"Number of milliseconds server will wait to shutdown gracefully."},
218 KV{.key =
"cache.num_diffs", .value =
"Number of diffs to cache. For more info, consult readme.md in etc"},
219 KV{.key =
"cache.num_markers", .value =
"Number of markers to cache."},
220 KV{.key =
"cache.num_cursors_from_diff", .value =
"Num of cursors that are different."},
221 KV{.key =
"cache.num_cursors_from_account", .value =
"Number of cursors from an account."},
222 KV{.key =
"cache.page_fetch_size", .value =
"Page fetch size for cache operations."},
223 KV{.key =
"cache.load", .value =
"Cache loading strategy ('sync' or 'async')."},
224 KV{.key =
"log_channels.[].channel",
225 .value =
"Name of the log channel."
226 "'RPC', 'ETL', and 'Performance'"},
227 KV{.key =
"log_channels.[].log_level",
228 .value =
"Log level for the specific log channel."
229 "`warning`, `error`, `fatal`"},
230 KV{.key =
"log_level",
231 .value =
"General logging level of Clio. This level will be applied to all log channels that do not have an "
232 "explicitly defined logging level."},
233 KV{.key =
"log_format", .value =
"Format string for log messages."},
234 KV{.key =
"log_to_console", .value =
"Enable or disable logging to console."},
235 KV{.key =
"log_directory", .value =
"Directory path for log files."},
236 KV{.key =
"log_rotation_size",
238 "Log rotation size in megabytes. When the log file reaches this particular size, a new log file starts."
240 KV{.key =
"log_directory_max_size", .value =
"Maximum size of the log directory in megabytes."},
241 KV{.key =
"log_rotation_hour_interval",
242 .value =
"Interval in hours for log rotation. If the current log file reaches this value in logging, a new "
244 KV{.key =
"log_tag_style", .value =
"Style for log tags."},
245 KV{.key =
"extractor_threads", .value =
"Number of extractor threads."},
246 KV{.key =
"read_only", .value =
"Indicates if the server should have read-only privileges."},
247 KV{.key =
"txn_threshold", .value =
"Transaction threshold value."},
248 KV{.key =
"start_sequence", .value =
"Starting ledger index."},
249 KV{.key =
"finish_sequence", .value =
"Ending ledger index."},
250 KV{.key =
"ssl_cert_file", .value =
"Path to the SSL certificate file."},
251 KV{.key =
"ssl_key_file", .value =
"Path to the SSL key file."},
252 KV{.key =
"api_version.default", .value =
"Default API version Clio will run on."},
253 KV{.key =
"api_version.min", .value =
"Minimum API version."},
254 KV{.key =
"api_version.max", .value =
"Maximum API version."},
255 KV{.key =
"migration.full_scan_threads", .value =
"The number of threads used to scan the table."},
256 KV{.key =
"migration.full_scan_jobs", .value =
"The number of coroutines used to scan the table."},
257 KV{.key =
"migration.cursors_per_job", .value =
"The number of cursors each coroutine will scan."}
Struct to represent a key-value pair.
Definition ConfigDescription.hpp:48
All the config description are stored and extracted from this class.
Definition ConfigDescription.hpp:45
static std::expected< void, Error > generateConfigDescriptionToFile(std::filesystem::path path)
Generate markdown file of all the clio config descriptions.
Definition ConfigDescription.hpp:81
static constexpr std::string_view get(std::string_view key)
Retrieves the description for a given key.
Definition ConfigDescription.hpp:67
static void writeConfigDescriptionToFile(std::ostream &file)
Writes to Config description to file.
Definition ConfigDescription.hpp:111
constexpr ClioConfigDescription()=default
Constructs a new Clio Config Description based on pre-existing descriptions.