Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SystemState.hpp
1#pragma once
2
3#include "util/config/ConfigDefinition.hpp"
4#include "util/log/Logger.hpp"
5#include "util/prometheus/Bool.hpp"
6#include "util/prometheus/Label.hpp"
7#include "util/prometheus/Prometheus.hpp"
8
9#include <boost/signals2/signal.hpp>
10#include <boost/signals2/variadic_signal.hpp>
11
12#include <atomic>
13#include <memory>
14
15namespace etl {
16
27 static std::shared_ptr<SystemState>
29 {
30 auto state = std::make_shared<SystemState>();
31 state->isStrictReadonly = config.get<bool>("read_only");
32 return state;
33 }
34
42 "read_only",
44 "Whether the process is in strict read-only mode"
45 );
46
48 util::prometheus::Bool isWriting = PrometheusService::boolMetric(
49 "etl_writing",
51 "Whether the process is writing to the database"
52 );
53
55 std::atomic_bool etlStarted{false};
56
67
75 boost::signals2::signal<void(WriteCommand)> writeCommandSignal;
76
85 "etl_amendment_blocked",
87 "Whether clio detected an amendment block"
88 );
89
97 "etl_corruption_detected",
99 "Whether clio detected a corruption that needs manual attention"
100 );
101
115 "etl_writing_deciding_fallback",
117 "Whether the cluster is using the fallback writer decision mechanism"
118 );
119};
120
121} // namespace etl
static util::prometheus::Bool boolMetric(std::string name, util::prometheus::Labels labels, std::optional< std::string > description=std::nullopt)
Get a bool based metric. It will be created if it doesn't exist.
Definition Prometheus.cpp:201
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:31
T get(std::string_view fullKey) const
Returns the specified value of given string if value exists.
Definition ConfigDefinition.hpp:85
Class representing a collection of Prometheus labels.
Definition Label.hpp:41
Represents the state of the ETL subsystem.
Definition SystemState.hpp:20
static std::shared_ptr< SystemState > makeSystemState(util::config::ClioConfigDefinition const &config)
Factory method to create a SystemState instance.
Definition SystemState.hpp:28
util::prometheus::Bool isAmendmentBlocked
Whether clio detected an amendment block.
Definition SystemState.hpp:84
WriteCommand
Commands for controlling the ETL writer state.
Definition SystemState.hpp:63
@ StopWriting
Definition SystemState.hpp:65
@ StartWriting
Definition SystemState.hpp:64
std::atomic_bool etlStarted
Shows whether ETL started monitor and ready to become a writer if needed.
Definition SystemState.hpp:55
util::prometheus::Bool isCorruptionDetected
Whether clio detected a corruption that needs manual attention.
Definition SystemState.hpp:96
boost::signals2::signal< void(WriteCommand)> writeCommandSignal
Signal for coordinating ETL writer state transitions.
Definition SystemState.hpp:75
util::prometheus::Bool isStrictReadonly
Whether the process is in strict read-only mode.
Definition SystemState.hpp:41
util::prometheus::Bool isWriting
Whether the process is writing to the database.
Definition SystemState.hpp:48
util::prometheus::Bool isWriterDecidingFallback
Whether the cluster is using the fallback writer decision mechanism.
Definition SystemState.hpp:114