3#include "util/Assert.hpp"
4#include "util/config/ConfigDefinition.hpp"
5#include "util/config/Error.hpp"
19namespace util::config {
33 std::string_view value;
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(
"[]")) {
108 file << getClioConfig().asArray(key);
110 file << getClioConfig().getValueView(key);
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{
131 KV{.key =
"database.type",
132 .value =
"Specifies the type of database used for storing and retrieving data required "
133 "by the Clio server. Both "
134 "ScyllaDB and Cassandra can serve as backends for Clio; however, this value "
135 "must be set to `cassandra`."},
136 KV{.key =
"database.cassandra.contact_points",
137 .value =
"A list of IP addresses or hostnames for the initial cluster nodes (Cassandra "
139 "the client connects to when establishing a database connection. If you're "
140 "running Clio locally, "
141 "set this value to `localhost` or `127.0.0.1`."},
142 KV{.key =
"database.cassandra.secure_connect_bundle",
143 .value =
"The configuration file that contains the necessary credentials and connection "
145 "securely connecting to a Cassandra database cluster."},
146 KV{.key =
"database.cassandra.port",
147 .value =
"The port number used to connect to the Cassandra database."},
148 KV{.key =
"database.cassandra.keyspace",
149 .value =
"The Cassandra keyspace to use for the database. If you don't provide a value, "
151 "`clio` by default."},
152 KV{.key =
"database.cassandra.replication_factor",
154 "Represents the number of replicated nodes for ScyllaDB. For more details see "
157 "Factor](https://university.scylladb.com/courses/scylla-essentials-overview/lessons/"
158 "high-availability/topic/fault-tolerance-replication-factor/)."},
159 KV{.key =
"database.cassandra.table_prefix",
161 "An optional field to specify a prefix for the Cassandra database table names."},
162 KV{.key =
"database.cassandra.max_write_requests_outstanding",
163 .value =
"Represents the maximum number of outstanding write requests. Write requests "
164 "are API calls that "
165 "write to the database."},
166 KV{.key =
"database.cassandra.max_read_requests_outstanding",
167 .value =
"Maximum number of outstanding read requests. Read requests are API calls that "
168 "read from the database."},
169 KV{.key =
"database.cassandra.threads",
170 .value =
"Represents the number of threads that will be used for database operations."},
171 KV{.key =
"database.cassandra.provider",
172 .value =
"The specific database backend provider we are using."},
173 KV{.key =
"database.cassandra.core_connections_per_host",
174 .value =
"The number of core connections per host for the Cassandra database."},
175 KV{.key =
"database.cassandra.queue_size_io",
176 .value =
"Defines the queue size of the input/output (I/O) operations in Cassandra."},
177 KV{.key =
"database.cassandra.write_batch_size",
178 .value =
"Represents the batch size for write operations in Cassandra."},
179 KV{.key =
"database.cassandra.connect_timeout",
180 .value =
"The maximum amount of time in seconds that the system waits for a database "
183 KV{.key =
"database.cassandra.request_timeout",
184 .value =
"The maximum amount of time in seconds that the system waits for a request to "
185 "be fetched from the "
187 KV{.key =
"database.cassandra.username",
188 .value =
"The username used for authenticating with the database."},
189 KV{.key =
"database.cassandra.password",
190 .value =
"The password used for authenticating with the database."},
191 KV{.key =
"database.cassandra.certfile",
192 .value =
"The path to the SSL/TLS certificate file used to establish a secure "
193 "connection between the client "
194 "and the Cassandra database."},
195 KV{.key =
"allow_no_etl",
196 .value =
"If set to `True`, allows Clio to start without any ETL source."},
197 KV{.key =
"etl_sources.[].ip", .value =
"The IP address of the ETL source."},
198 KV{.key =
"etl_sources.[].ws_port", .value =
"The WebSocket port of the ETL source."},
199 KV{.key =
"etl_sources.[].grpc_port", .value =
"The gRPC port of the ETL source."},
200 KV{.key =
"forwarding.cache_timeout",
201 .value =
"Specifies the timeout duration (in seconds) for the forwarding cache used in "
203 "communication. A value of `0` means disabling this feature."},
204 KV{.key =
"forwarding.request_timeout",
205 .value =
"Specifies the timeout duration (in seconds) for the forwarding request used "
208 KV{.key =
"rpc.cache_timeout",
209 .value =
"Specifies the timeout duration (in seconds) for RPC cache response to "
210 "timeout. A value of `0` "
211 "means disabling this feature."},
212 KV{.key =
"num_markers",
213 .value =
"Specifies the number of coroutines used to download the initial ledger."},
214 KV{.key =
"dos_guard.whitelist.[]",
215 .value =
"The list of IP addresses to whitelist for DOS protection."},
216 KV{.key =
"dos_guard.max_fetches",
217 .value =
"The maximum number of fetch operations allowed by DOS guard."},
218 KV{.key =
"dos_guard.max_connections",
219 .value =
"The maximum number of concurrent connections for a specific IP address."},
220 KV{.key =
"dos_guard.max_requests",
221 .value =
"The maximum number of requests allowed for a specific IP address."},
222 KV{.key =
"dos_guard.sweep_interval",
223 .value =
"Interval in seconds for DOS guard to sweep(clear) its state."},
224 KV{.key =
"workers", .value =
"The number of threads used to process RPC requests."},
225 KV{.key =
"server.ip", .value =
"The IP address of the Clio HTTP server."},
226 KV{.key =
"server.port", .value =
"The port number of the Clio HTTP server."},
227 KV{.key =
"server.max_queue_size",
228 .value =
"The maximum size of the server's request queue. If set to `0`, this means "
229 "there is no queue size "
231 KV{.key =
"server.local_admin",
232 .value =
"Indicates if requests from `localhost` are allowed to call Clio admin-only "
233 "APIs. Note that this "
234 "setting cannot be enabled "
235 "together with [server.admin_password](#serveradmin_password)."},
236 KV{.key =
"server.admin_password",
237 .value =
"The password for Clio admin-only APIs. Note that this setting cannot be "
238 "enabled together with "
239 "[server.local_admin](#serveradmin_password)."},
240 KV{.key =
"server.processing_policy",
241 .value =
"For the `sequent` policy, requests from a single client connection are "
242 "processed one by one, with "
243 "the next request read only after the previous one is processed. For the "
244 "`parallel` policy, Clio "
245 "will accept all requests and process them in parallel, sending a reply for "
246 "each request as soon "
248 KV{.key =
"server.parallel_requests_limit",
249 .value =
"This is an optional parameter, used only if the `processing_strategy` is "
250 "`parallel`. It limits "
251 "the number of requests processed in parallel for a single client connection. "
252 "If not specified, no "
253 "limit is enforced."},
254 KV{.key =
"server.ws_max_sending_queue_size",
255 .value =
"Maximum queue size for sending subscription data to clients. This queue "
256 "buffers data when a "
257 "client is slow to receive it, ensuring delivery once the client is ready."},
258 KV{.key =
"server.proxy.ips.[]",
260 "List of proxy ip addresses. When Clio receives a request from proxy it will use "
261 "`Forwarded` value (if any) as client ip. When this option is used together with "
262 "`server.proxy.tokens` Clio will identify proxy by ip or by token."},
263 KV{.key =
"server.proxy.tokens.[]",
264 .value =
"List of tokens in identifying request as a request from proxy. Token should "
266 "`X-Proxy-Token` header, e.g. "
267 "`X-Proxy-Token: <very_secret_token>'. When Clio receives a request from proxy "
268 "it will use 'Forwarded` value (if any) to get client ip. When this option is "
269 "used together with "
270 "'server.proxy.ips' Clio will identify proxy by ip or by token."},
271 KV{.key =
"prometheus.enabled", .value =
"Enables or disables Prometheus metrics."},
272 KV{.key =
"prometheus.compress_reply",
273 .value =
"Enables or disables compression of Prometheus responses."},
274 KV{.key =
"io_threads",
275 .value =
"The number of input/output (I/O) threads. The value cannot be less than `1`."},
276 KV{.key =
"subscription_workers",
277 .value =
"The number of worker threads or processes that are responsible for managing "
279 "subscription-based tasks from `rippled`."},
280 KV{.key =
"graceful_period",
281 .value =
"The number of seconds the server waits to shutdown gracefully. If Clio does "
283 "gracefully after the specified value, it will be killed instead."},
284 KV{.key =
"cache.num_diffs",
285 .value =
"The number of cursors generated is the number of changed (without counting "
286 "deleted) objects in "
287 "the latest `cache.num_diffs` number of ledgers. Cursors are workers that load "
289 "from the position of markers concurrently. For more information, please read "
290 "[README.md](../src/etl/README.md)."},
291 KV{.key =
"cache.num_markers",
292 .value =
"Specifies how many markers are placed randomly within the cache. These "
293 "markers define the "
294 "positions on the ledger that will be loaded concurrently by the workers. The "
295 "higher the number, "
296 "the more places within the cache we potentially cover."},
297 KV{.key =
"cache.num_cursors_from_diff",
298 .value =
"`cache.num_cursors_from_diff` number of cursors are generated by looking at "
299 "the number of changed "
300 "objects in the most recent ledger. If number of changed objects in current "
301 "ledger is not enough, "
302 "it will keep reading previous ledgers until it hit "
303 "`cache.num_cursors_from_diff`. If set to `0`, "
304 "the system defaults to generating cursors based on `cache.num_diffs`."},
305 KV{.key =
"cache.num_cursors_from_account",
306 .value =
"`cache.num_cursors_from_diff` of cursors are generated by reading accounts in "
307 "`account_tx` table. "
308 "If set to `0`, the system defaults to generating cursors based on "
309 "`cache.num_diffs`."},
310 KV{.key =
"cache.page_fetch_size",
311 .value =
"The number of ledger objects to fetch concurrently per marker."},
312 KV{.key =
"cache.limit_load_in_cluster",
313 .value =
"If enabled only one clio node in a cluster (sharing the same database) will "
314 "load cache at a time"},
315 KV{.key =
"cache.load", .value =
"The strategy used for Cache loading."},
316 KV{.key =
"cache.file.path",
317 .value =
"The path to a file where cache will be saved to on shutdown and loaded from "
319 "If the file couldn't be read Clio will load cache as usual (from DB or from "
321 KV{.key =
"cache.file.max_sequence_age",
322 .value =
"Max allowed difference between the latest sequence in DB and in cache file. "
323 "If the cache file is "
324 "too old (contains too low latest sequence) Clio will reject using it."},
325 KV{.key =
"cache.file.async_save",
327 "When false, Clio waits for cache saving to finish before shutting down. When true, "
328 "cache saving runs in parallel with other shutdown operations."},
329 KV{.key =
"log.channels.[].channel", .value =
"The name of the log channel."},
330 KV{.key =
"log.channels.[].level", .value =
"The log level for the specific log channel."},
331 KV{.key =
"log.level",
332 .value =
"The general logging level of Clio. This level is applied to all log channels "
333 "that do not have an "
334 "explicitly defined logging level."},
335 KV{.key =
"log.format",
336 .value = R
"(The format string for log messages using spdlog format patterns.
338Each of the variables expands like so:
340- `%Y-%m-%d %H:%M:%S.%f`: The full date and time of the log entry with microsecond precision
341- `%^`: Start color range
342- `%3!l`: The severity (aka log level) the entry was sent at stripped to 3 characters
343- `%n`: The logger name (channel) that this log entry was sent to
344- `%$`: End color range
345- `%v`: The actual log message
347Some additional variables that might be useful:
349- `%@`: A partial path to the C++ file and the line number in the said file (`src/file/path:linenumber`)
350- `%t`: The ID of the thread the log entry is written from
352Documentation can be found at: <https://github.com/gabime/spdlog/wiki/Custom-formatting>.)"},
353 KV{.key = "log.is_async", .value =
"Whether spdlog is asynchronous or not."},
354 KV{.key =
"log.enable_console", .value =
"Enables or disables logging to the console."},
355 KV{.key =
"log.directory", .value =
"The directory path for the log files."},
356 KV{.key =
"log.rotation_size",
357 .value =
"The log rotation size in megabytes. When the log file reaches this particular "
360 KV{.key =
"log.directory_max_files",
361 .value =
"The maximum number of log files in the directory."},
362 KV{.key =
"log.rotate",
363 .value =
"Enables or disables log file rotation. When disabled, a single log file is "
364 "used without size-based rotation. Useful when rotation is managed externally "
365 "(e.g., via logrotate)."},
366 KV{.key =
"log.tag_style",
367 .value =
"Log tags are unique identifiers for log messages. `uint`/`int` starts logging "
368 "from 0 and increments, "
369 "making it faster. In contrast, `uuid` generates a random unique identifier, "
370 "which adds overhead."},
371 KV{.key =
"extractor_threads",
372 .value =
"Number of threads used to extract data from ETL source."},
373 KV{.key =
"read_only",
374 .value =
"Indicates if the server is allowed to write data to the database."},
375 KV{.key =
"start_sequence",
376 .value =
"If specified, the ledger index Clio will start writing to the database from."},
377 KV{.key =
"finish_sequence",
378 .value =
"If specified, the final ledger that Clio will write to the database."},
379 KV{.key =
"ssl_cert_file", .value =
"The path to the SSL certificate file."},
380 KV{.key =
"ssl_key_file", .value =
"The path to the SSL key file."},
381 KV{.key =
"api_version.default",
382 .value =
"The default API version that the Clio server will run on."},
383 KV{.key =
"api_version.min", .value =
"The minimum API version allowed to use."},
384 KV{.key =
"api_version.max", .value =
"The maximum API version allowed to use."},
385 KV{.key =
"migration.full_scan_threads",
386 .value =
"The number of threads used to scan the table."},
387 KV{.key =
"migration.full_scan_jobs",
388 .value =
"The number of coroutines used to scan the table."},
389 KV{.key =
"migration.cursors_per_job", .value =
"The number of cursors each job will scan."}
Struct to represent a key-value pair.
Definition ConfigDescription.hpp:31
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.