3#include "util/Assert.hpp"
4#include "util/config/ConfigDefinition.hpp"
5#include "util/config/Error.hpp"
50 [[nodiscard]]
static constexpr std::string_view
51 get(std::string_view key)
54 std::ranges::find_if(kConfigDescription, [&](
auto const& v) {
return v.key == key; });
55 ASSERT(itr != kConfigDescription.end(),
"Key {} doesn't exist in config", key);
65 [[nodiscard]]
static std::expected<void, Error>
68 namespace fs = std::filesystem;
71 auto const dir = path.parent_path();
72 if (!dir.empty() && !fs::exists(dir)) {
73 return std::unexpected<Error>{fmt::format(
74 "Error: Directory '{}' does not exist or provided path is invalid", dir.string()
78 std::ofstream file(path.string());
79 if (!file.is_open()) {
80 return std::unexpected{
81 fmt::format(
"Failed to create file '{}': {}", path.string(), std::strerror(errno))
88 std::cout <<
"Markdown file generated successfully: " << path <<
"\n";
100 file << kConfigDescriptionHeader;
102 for (
auto const& [key, val] : kConfigDescription) {
103 file <<
"\n### " << key <<
"\n\n";
107 if (key.contains(
"[]")) {
112 file <<
"- **Description**: " << val <<
"\n";
117 static constexpr auto kConfigDescriptionHeader =
118 R
"(# Clio Config Description
120This document provides a list of all available Clio configuration properties in detail.
123> Dot notation in configuration key names represents nested fields.
124> For example, **database.scylladb** refers to the _scylladb_ field inside the _database_ object.
125> If a key name includes "[]", it indicates that the nested field is an array (e.g., etl_sources.[]).
127## Configuration Details
130 static constexpr auto kConfigDescription = std::array{
132 .key =
"database.type",
133 .value =
"Specifies the type of database used for storing and retrieving data "
134 "required by the Clio server. Both ScyllaDB and Cassandra can serve as "
135 "backends for Clio; however, this value must be set to `cassandra`.",
138 .key =
"database.cassandra.contact_points",
140 "A list of IP addresses or hostnames for the initial cluster nodes (Cassandra or "
141 "ScyllaDB) that the client connects to when establishing a database connection. "
142 "If you're running Clio locally, set this value to `localhost` or `127.0.0.1`.",
145 .key =
"database.cassandra.secure_connect_bundle",
146 .value =
"The configuration file that contains the necessary credentials and "
147 "connection details for securely connecting to a Cassandra database cluster.",
150 .key =
"database.cassandra.port",
151 .value =
"The port number used to connect to the Cassandra database.",
154 .key =
"database.cassandra.keyspace",
155 .value =
"The Cassandra keyspace to use for the database. If you don't provide a "
156 "value, this is set to `clio` by default.",
159 .key =
"database.cassandra.replication_factor",
160 .value =
"Represents the number of replicated nodes for ScyllaDB. For more details "
161 "see [Fault Tolerance Replication Factor](https://university.scylladb.com/"
162 "courses/scylla-essentials-overview/lessons/high-availability/topic/"
163 "fault-tolerance-replication-factor/).",
166 .key =
"database.cassandra.table_prefix",
168 "An optional field to specify a prefix for the Cassandra database table names.",
171 .key =
"database.cassandra.max_write_requests_outstanding",
172 .value =
"Represents the maximum number of outstanding write requests. Write requests "
173 "are API calls that write to the database.",
176 .key =
"database.cassandra.max_read_requests_outstanding",
177 .value =
"Maximum number of outstanding read requests. Read requests are API calls "
178 "that read from the database.",
181 .key =
"database.cassandra.threads",
182 .value =
"Represents the number of threads that will be used for database operations.",
185 .key =
"database.cassandra.provider",
186 .value =
"The specific database backend provider we are using.",
189 .key =
"database.cassandra.core_connections_per_host",
190 .value =
"The number of core connections per host for the Cassandra database.",
193 .key =
"database.cassandra.queue_size_io",
194 .value =
"Defines the queue size of the input/output (I/O) operations in Cassandra.",
197 .key =
"database.cassandra.write_batch_size",
198 .value =
"Represents the batch size for write operations in Cassandra.",
201 .key =
"database.cassandra.connect_timeout",
202 .value =
"The maximum amount of time in seconds that the system waits for a database "
203 "connection to be established.",
206 .key =
"database.cassandra.request_timeout",
207 .value =
"The maximum amount of time in seconds that the system waits for a request "
208 "to be fetched from the database. Should be set higher than the server side "
209 "read timeout. If omitted, no request timeout is applied.",
212 .key =
"database.cassandra.initial_request_retry_delay",
213 .value =
"How long in seconds to wait before the first retry of a database request "
214 "that failed with a transient error.",
217 .key =
"database.cassandra.max_request_retry_delay",
218 .value =
"Upper bound in seconds for the exponential backoff between retries of a "
222 .key =
"database.cassandra.username",
223 .value =
"The username used for authenticating with the database.",
226 .key =
"database.cassandra.password",
227 .value =
"The password used for authenticating with the database.",
230 .key =
"database.cassandra.certfile",
231 .value =
"The path to the SSL/TLS certificate file used to establish a secure "
232 "connection between the client and the Cassandra database.",
235 .key =
"allow_no_etl",
236 .value =
"If set to `True`, allows Clio to start without any ETL source.",
238 KV{.key =
"etl_sources.[].ip", .value =
"The IP address of the ETL source."},
239 KV{.key =
"etl_sources.[].ws_port", .value =
"The WebSocket port of the ETL source."},
240 KV{.key =
"etl_sources.[].grpc_port", .value =
"The gRPC port of the ETL source."},
242 .key =
"forwarding.cache_timeout",
243 .value =
"Specifies the timeout duration (in seconds) for the forwarding cache used "
244 "in `rippled` communication. A value of `0` means disabling this feature.",
247 .key =
"forwarding.request_timeout",
248 .value =
"Specifies the timeout duration (in seconds) for the forwarding request used "
249 "in `rippled` communication.",
252 .key =
"rpc.cache_timeout",
253 .value =
"Specifies the timeout duration (in seconds) for RPC cache response to "
254 "timeout. A value of `0` means disabling this feature.",
257 .key =
"num_markers",
258 .value =
"Specifies the number of coroutines used to download the initial ledger.",
261 .key =
"dos_guard.whitelist.[]",
262 .value =
"The list of IP addresses to whitelist for DOS protection.",
265 .key =
"dos_guard.max_fetches",
266 .value =
"The maximum number of fetch operations allowed by DOS guard.",
269 .key =
"dos_guard.max_connections",
270 .value =
"The maximum number of concurrent connections for a specific IP address.",
273 .key =
"dos_guard.max_requests",
274 .value =
"The maximum number of requests allowed for a specific IP address.",
277 .key =
"dos_guard.sweep_interval",
278 .value =
"Interval in seconds for DOS guard to sweep(clear) its state.",
280 KV{.key =
"workers", .value =
"The number of threads used to process RPC requests."},
281 KV{.key =
"server.ip", .value =
"The IP address of the Clio HTTP server."},
282 KV{.key =
"server.port", .value =
"The port number of the Clio HTTP server."},
284 .key =
"server.max_queue_size",
285 .value =
"The maximum size of the server's request queue. If set to `0`, this means "
286 "there is no queue size limit.",
289 .key =
"server.local_admin",
290 .value =
"Indicates if requests from `localhost` are allowed to call Clio admin-only "
291 "APIs. Note that this setting cannot be enabled together with "
292 "[server.admin_password](#serveradmin_password).",
295 .key =
"server.admin_password",
296 .value =
"The password for Clio admin-only APIs. Note that this setting cannot be "
297 "enabled together with [server.local_admin](#serveradmin_password).",
300 .key =
"server.processing_policy",
302 "For the `sequent` policy, requests from a single client connection are processed "
303 "one by one, with the next request read only after the previous one is processed. "
304 "For the `parallel` policy, Clio will accept all requests and process them in "
305 "parallel, sending a reply for each request as soon as it is ready.",
308 .key =
"server.parallel_requests_limit",
309 .value =
"This is an optional parameter, used only if the `processing_strategy` is "
310 "`parallel`. It limits the number of requests processed in parallel for a "
311 "single client connection. If not specified, no limit is enforced.",
314 .key =
"server.ws_max_sending_queue_size",
315 .value =
"Maximum queue size for sending subscription data to clients. This queue "
316 "buffers data when a client is slow to receive it, ensuring delivery once "
317 "the client is ready.",
320 .key =
"server.proxy.ips.[]",
322 "List of proxy ip addresses. When Clio receives a request from proxy it will use "
323 "`Forwarded` value (if any) as client ip. When this option is used together with "
324 "`server.proxy.tokens` Clio will identify proxy by ip or by token.",
327 .key =
"server.proxy.tokens.[]",
328 .value =
"List of tokens in identifying request as a request from proxy. Token should "
329 "be provided in `X-Proxy-Token` header, e.g. `X-Proxy-Token: "
330 "<very_secret_token>'. When Clio receives a request from proxy it will use "
331 "'Forwarded` value (if any) to get client ip. When this option is used "
332 "together with 'server.proxy.ips' Clio will identify proxy by ip or by token.",
334 KV{.key =
"prometheus.enabled", .value =
"Enables or disables Prometheus metrics."},
336 .key =
"prometheus.compress_reply",
337 .value =
"Enables or disables compression of Prometheus responses.",
341 .value =
"The number of input/output (I/O) threads. The value cannot be less than `1`.",
344 .key =
"subscription_workers",
345 .value =
"The number of worker threads or processes that are responsible for managing "
346 "and processing subscription-based tasks from `rippled`.",
349 .key =
"graceful_period",
351 "The number of seconds the server waits to shutdown gracefully. If Clio does not "
352 "shutdown gracefully after the specified value, it will be killed instead.",
355 .key =
"cache.num_diffs",
357 "The number of cursors generated is the number of changed (without counting "
358 "deleted) objects in the latest `cache.num_diffs` number of ledgers. Cursors are "
359 "workers that load the ledger cache from the position of markers concurrently. "
360 "For more information, please read [README.md](../src/etl/README.md).",
363 .key =
"cache.num_markers",
364 .value =
"Specifies how many markers are placed randomly within the cache. These "
365 "markers define the positions on the ledger that will be loaded concurrently "
366 "by the workers. The higher the number, the more places within the cache we "
367 "potentially cover.",
370 .key =
"cache.num_cursors_from_diff",
371 .value =
"`cache.num_cursors_from_diff` number of cursors are generated by looking at "
372 "the number of changed objects in the most recent ledger. If number of "
373 "changed objects in current ledger is not enough, it will keep reading "
374 "previous ledgers until it hit `cache.num_cursors_from_diff`. If set to `0`, "
375 "the system defaults to generating cursors based on `cache.num_diffs`.",
378 .key =
"cache.num_cursors_from_account",
379 .value =
"`cache.num_cursors_from_diff` of cursors are generated by reading accounts "
380 "in `account_tx` table. If set to `0`, the system defaults to generating "
381 "cursors based on `cache.num_diffs`.",
384 .key =
"cache.page_fetch_size",
385 .value =
"The number of ledger objects to fetch concurrently per marker.",
388 .key =
"cache.limit_load_in_cluster",
389 .value =
"If enabled only one clio node in a cluster (sharing the same database) will "
390 "load cache at a time",
392 KV{.key =
"cache.load", .value =
"The strategy used for Cache loading."},
394 .key =
"cache.file.path",
395 .value =
"The path to a file where cache will be saved to on shutdown and loaded from "
396 "on startup. If the file couldn't be read Clio will load cache as usual "
397 "(from DB or from rippled).",
400 .key =
"cache.file.max_sequence_age",
401 .value =
"Max allowed difference between the latest sequence in DB and in cache file. "
402 "If the cache file is too old (contains too low latest sequence) Clio will "
406 .key =
"cache.file.async_save",
407 .value =
"When false, Clio waits for cache saving to finish before shutting down. "
408 "When true, cache saving runs in parallel with other shutdown operations.",
410 KV{.key =
"log.channels.[].channel", .value =
"The name of the log channel."},
411 KV{.key =
"log.channels.[].level", .value =
"The log level for the specific log channel."},
414 .value =
"The general logging level of Clio. This level is applied to all log "
415 "channels that do not have an explicitly defined logging level.",
419 .value = R
"(The format string for log messages using spdlog format patterns.
421Each of the variables expands like so:
423- `%Y-%m-%d %H:%M:%S.%f`: The full date and time of the log entry with microsecond precision
424- `%^`: Start color range
425- `%3!l`: The severity (aka log level) the entry was sent at stripped to 3 characters
426- `%n`: The logger name (channel) that this log entry was sent to
427- `%$`: End color range
428- `%v`: The actual log message
430Some additional variables that might be useful:
432- `%@`: A partial path to the C++ file and the line number in the said file (`src/file/path:linenumber`)
433- `%t`: The ID of the thread the log entry is written from
435Documentation can be found at: <https://github.com/gabime/spdlog/wiki/Custom-formatting>.)",
437 KV{.key = "log.is_async", .value =
"Whether spdlog is asynchronous or not."},
438 KV{.key =
"log.enable_console", .value =
"Enables or disables logging to the console."},
439 KV{.key =
"log.directory", .value =
"The directory path for the log files."},
441 .key =
"log.rotation_size",
442 .value =
"The log rotation size in megabytes. When the log file reaches this "
443 "particular size, a new log file starts.",
446 .key =
"log.directory_max_files",
447 .value =
"The maximum number of log files in the directory.",
451 .value =
"Enables or disables log file rotation. When disabled, a single log file is "
452 "used without size-based rotation. Useful when rotation is managed "
453 "externally (e.g., via logrotate).",
456 .key =
"log.tag_style",
457 .value =
"Log tags are unique identifiers for log messages. `uint`/`int` starts "
458 "logging from 0 and increments, making it faster. In contrast, `uuid` "
459 "generates a random unique identifier, which adds overhead.",
462 .key =
"extractor_threads",
463 .value =
"Number of threads used to extract data from ETL source.",
467 .value =
"Indicates if the server is allowed to write data to the database.",
470 .key =
"start_sequence",
471 .value =
"If specified, the ledger index Clio will start writing to the database from.",
474 .key =
"finish_sequence",
475 .value =
"If specified, the final ledger that Clio will write to the database.",
477 KV{.key =
"ssl_cert_file", .value =
"The path to the SSL certificate file."},
478 KV{.key =
"ssl_key_file", .value =
"The path to the SSL key file."},
480 .key =
"api_version.default",
481 .value =
"The default API version that the Clio server will run on.",
483 KV{.key =
"api_version.min", .value =
"The minimum API version allowed to use."},
484 KV{.key =
"api_version.max", .value =
"The maximum API version allowed to use."},
486 .key =
"migration.full_scan_threads",
487 .value =
"The number of threads used to scan the table.",
490 .key =
"migration.full_scan_jobs",
491 .value =
"The number of coroutines used to scan the table.",
494 .key =
"migration.cursors_per_job",
495 .value =
"The number of cursors each job will scan.",
Array const & asArray(std::string_view key) const
Returns the Array object associated with the specified key.
Definition ConfigDefinition.cpp:125
ValueView getValueView(std::string_view fullKey) const
Returns the specified ValueView object associated with the key.
Definition ConfigDefinition.cpp:98
Clio configuration: definitions of the supported keys, their types, constraints and defaults,...
Definition HandlerRegistry.hpp:24
ClioConfigDefinition & getClioConfig()
Full Clio Configuration definition.
Definition ConfigDefinition.cpp:243
Struct to represent a key-value pair.
Definition ConfigDescription.hpp:31
std::string_view key
The config key.
Definition ConfigDescription.hpp:32
std::string_view value
The description of the config key.
Definition ConfigDescription.hpp:33
static std::expected< void, Error > generateConfigDescriptionToFile(std::filesystem::path path)
Generate markdown file of all the clio config descriptions.
Definition ConfigDescription.hpp:66
static constexpr std::string_view get(std::string_view key)
Retrieves the description for a given key.
Definition ConfigDescription.hpp:51
static void writeConfigDescriptionToFile(std::ostream &file)
Writes to Config description to file.
Definition ConfigDescription.hpp:98
constexpr ClioConfigDescription()=default
Constructs a new Clio Config Description based on pre-existing descriptions.