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 "etl/WriterState.hpp"
23
24#include <boost/json/conversion.hpp>
25#include <boost/json/value.hpp>
26#include <boost/uuid/uuid.hpp>
27
28#include <chrono>
29#include <memory>
30
31namespace cluster {
32
36struct ClioNode {
40 static constexpr char const* kTIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ";
41
55 enum class DbRole { ReadOnly = 0, LoadingCache = 1, NotWriter = 2, Writer = 3, Fallback = 4, MAX = 4 };
56
57 using Uuid = std::shared_ptr<boost::uuids::uuid>;
58 using CUuid = std::shared_ptr<boost::uuids::uuid const>;
59
60 Uuid uuid;
61 std::chrono::system_clock::time_point updateTime;
63
71 static ClioNode
72 from(Uuid uuid, etl::WriterStateInterface const& writerState);
73};
74
75void
76tag_invoke(boost::json::value_from_tag, boost::json::value& jv, ClioNode const& node);
77
79tag_invoke(boost::json::value_to_tag<ClioNode>, boost::json::value const& jv);
80
81} // namespace cluster
Interface for managing writer state in the ETL subsystem.
Definition WriterState.hpp:35
Represents a node in the cluster.
Definition ClioNode.hpp:36
Uuid uuid
The UUID of the node.
Definition ClioNode.hpp:60
DbRole dbRole
The database role of the node.
Definition ClioNode.hpp:62
std::chrono::system_clock::time_point updateTime
The time the data about the node was last updated.
Definition ClioNode.hpp:61
DbRole
Database role of a node in the cluster.
Definition ClioNode.hpp:55
static constexpr char const * kTIME_FORMAT
The format of the time to store in the database.
Definition ClioNode.hpp:40
static ClioNode from(Uuid uuid, etl::WriterStateInterface const &writerState)
Create a ClioNode from writer state.
Definition ClioNode.cpp:50