Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MigrationInspectorBase.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 "migration/MigrationInspectorInterface.hpp"
23#include "migration/MigratiorStatus.hpp"
24
25#include <memory>
26#include <ranges>
27#include <string>
28#include <tuple>
29#include <vector>
30
31namespace migration::impl {
32
39template <typename SupportedMigrators>
41protected:
42 SupportedMigrators migrators_;
43
44public:
51 std::shared_ptr<typename SupportedMigrators::BackendType> backend
52 )
53 : migrators_{std::move(backend)}
54 {
55 }
56
63 std::vector<std::tuple<std::string, MigratorStatus>>
64 allMigratorsStatusPairs() const override
65 {
66 return migrators_.getMigratorsStatus();
67 }
68
76 getMigratorStatusByName(std::string const& name) const override
77 {
78 return migrators_.getMigratorStatus(name);
79 }
80
86 std::vector<std::string>
87 allMigratorsNames() const override
88 {
89 auto const names = migrators_.getMigratorNames();
90 return std::vector<std::string>{names.begin(), names.end()};
91 }
92
99 std::string
100 getMigratorDescriptionByName(std::string const& name) const override
101 {
102 return migrators_.getMigratorDescription(name);
103 }
104
110 bool
111 isBlockingClio() const override
112 {
113 return std::ranges::any_of(migrators_.getMigratorNames(), [&](auto const& migrator) {
114 if (auto canBlock = migrators_.canMigratorBlockClio(migrator); canBlock.has_value() and
115 *canBlock and
116 migrators_.getMigratorStatus(std::string(migrator)) ==
117 MigratorStatus::Status::NotMigrated) {
118 return true;
119 }
120 return false;
121 });
122 }
123};
124
125} // namespace migration::impl
The status of a migrator, it provides the helper functions to convert the status to string and vice v...
Definition MigratiorStatus.hpp:32
std::vector< std::tuple< std::string, MigratorStatus > > allMigratorsStatusPairs() const override
Get the status of all the migrators.
Definition MigrationInspectorBase.hpp:64
MigrationInspectorBase(std::shared_ptr< typename SupportedMigrators::BackendType > backend)
Construct a new Cassandra Migration Inspector object.
Definition MigrationInspectorBase.hpp:50
bool isBlockingClio() const override
Return if there is incomplete migrator blocking the server.
Definition MigrationInspectorBase.hpp:111
std::string getMigratorDescriptionByName(std::string const &name) const override
Get the description of a migrator by its name.
Definition MigrationInspectorBase.hpp:100
MigratorStatus getMigratorStatusByName(std::string const &name) const override
Get the status of a migrator by its name.
Definition MigrationInspectorBase.hpp:76
std::vector< std::string > allMigratorsNames() const override
Get all registered migrators' names.
Definition MigrationInspectorBase.hpp:87
The interface for the migration inspector.The Clio server application will use this interface to insp...
Definition MigrationInspectorInterface.hpp:34