mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
100 lines
3.9 KiB
C++
100 lines
3.9 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of clio: https://github.com/XRPLF/clio
|
|
Copyright (c) 2023, the clio developers.
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#pragma once
|
|
|
|
#include "util/prometheus/Bool.hpp"
|
|
#include "util/prometheus/Label.hpp"
|
|
#include "util/prometheus/Prometheus.hpp"
|
|
|
|
#include <boost/signals2/signal.hpp>
|
|
#include <boost/signals2/variadic_signal.hpp>
|
|
|
|
namespace etl {
|
|
|
|
/**
|
|
* @brief Represents the state of the ETL subsystem.
|
|
*/
|
|
struct SystemState {
|
|
/**
|
|
* @brief Whether the process is in strict read-only mode.
|
|
*
|
|
* In strict read-only mode, the process will never attempt to become the ETL writer, and will only publish ledgers
|
|
* as they are written to the database.
|
|
*/
|
|
util::prometheus::Bool isStrictReadonly = PrometheusService::boolMetric(
|
|
"read_only",
|
|
util::prometheus::Labels{},
|
|
"Whether the process is in strict read-only mode"
|
|
);
|
|
|
|
/** @brief Whether the process is writing to the database. */
|
|
util::prometheus::Bool isWriting = PrometheusService::boolMetric(
|
|
"etl_writing",
|
|
util::prometheus::Labels{},
|
|
"Whether the process is writing to the database"
|
|
);
|
|
|
|
/**
|
|
* @brief Commands for controlling the ETL writer state.
|
|
*
|
|
* These commands are emitted via writeCommandSignal to coordinate writer state transitions across components.
|
|
*/
|
|
enum class WriteCommand {
|
|
StartWriting, /**< Request to attempt taking over as the ETL writer */
|
|
StopWriting /**< Request to give up the ETL writer role (e.g., due to write conflict) */
|
|
};
|
|
|
|
/**
|
|
* @brief Signal for coordinating ETL writer state transitions.
|
|
*
|
|
* This signal allows components to request changes to the writer state without direct coupling.
|
|
* - Emitted with StartWriting when database stalls and node should attempt to become writer
|
|
* - Emitted with StopWriting when write conflicts are detected
|
|
*/
|
|
boost::signals2::signal<void(WriteCommand)> writeCommandSignal;
|
|
|
|
/**
|
|
* @brief Whether clio detected an amendment block.
|
|
*
|
|
* Being amendment blocked means that Clio was compiled with libxrpl that does not yet support some field that
|
|
* arrived from rippled and therefore can't extract the ledger diff. When this happens, Clio can't proceed with ETL
|
|
* and should log this error and only handle RPC requests.
|
|
*/
|
|
util::prometheus::Bool isAmendmentBlocked = PrometheusService::boolMetric(
|
|
"etl_amendment_blocked",
|
|
util::prometheus::Labels{},
|
|
"Whether clio detected an amendment block"
|
|
);
|
|
|
|
/**
|
|
* @brief Whether clio detected a corruption that needs manual attention.
|
|
*
|
|
* When corruption is detected, Clio should disable cache and stop the cache loading process in order to prevent
|
|
* further corruption.
|
|
*/
|
|
util::prometheus::Bool isCorruptionDetected = PrometheusService::boolMetric(
|
|
"etl_corruption_detected",
|
|
util::prometheus::Labels{},
|
|
"Whether clio detected a corruption that needs manual attention"
|
|
);
|
|
};
|
|
|
|
} // namespace etl
|