Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
ClioNode.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "data/LedgerCacheLoadingState.hpp"
23#include "etl/WriterState.hpp"
24
25#include <boost/json/conversion.hpp>
26#include <boost/json/value.hpp>
27#include <boost/uuid/uuid.hpp>
28
29#include <chrono>
30#include <memory>
31
32namespace cluster {
33
37struct ClioNode {
41 static constexpr char const* kTIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ";
42
59 enum class DbRole {
60 ReadOnly = 0,
61 NotWriter = 1,
62 Writer = 2,
63 Fallback = 3,
64 FallbackRecovery = 4,
65 Max = 4
66 };
67
68 using Uuid = std::shared_ptr<boost::uuids::uuid>;
69 using CUuid = std::shared_ptr<boost::uuids::uuid const>;
70
71 Uuid uuid;
72 std::chrono::system_clock::time_point
78
87 static ClioNode
88 from(
89 Uuid uuid,
90 etl::WriterStateInterface const& writerState,
91 data::LedgerCacheLoadingStateInterface const& cacheLoadingState
92 );
93};
94
95void
96tag_invoke(boost::json::value_from_tag, boost::json::value& jv, ClioNode const& node);
97
99tag_invoke(boost::json::value_to_tag<ClioNode>, boost::json::value const& jv);
100
101} // namespace cluster
Interface for coordinating cache loading permissions across a cluster.
Definition LedgerCacheLoadingState.hpp:37
Interface for managing writer state in the ETL subsystem.
Definition WriterState.hpp:40
Represents a node in the cluster.
Definition ClioNode.hpp:37
bool etlStarted
Whether the ETL monitor has started on this node.
Definition ClioNode.hpp:75
bool cacheIsCurrentlyLoading
Whether this node is currently loading the ledger cache.
Definition ClioNode.hpp:77
bool cacheIsFull
Whether the ledger cache is fully loaded on this node.
Definition ClioNode.hpp:76
Uuid uuid
The UUID of the node.
Definition ClioNode.hpp:71
DbRole dbRole
The database role of the node.
Definition ClioNode.hpp:74
std::chrono::system_clock::time_point updateTime
The time the data about the node was last updated.
Definition ClioNode.hpp:73
DbRole
Database role of a node in the cluster.
Definition ClioNode.hpp:59
static constexpr char const * kTIME_FORMAT
The format of the time to store in the database.
Definition ClioNode.hpp:41
static ClioNode from(Uuid uuid, etl::WriterStateInterface const &writerState, data::LedgerCacheLoadingStateInterface const &cacheLoadingState)
Create a ClioNode from writer state and cache loading state.
Definition ClioNode.cpp:55