Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MigrationApplication.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, 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/LedgerCache.hpp"
23#include "migration/MigrationManagerInterface.hpp"
24#include "util/newconfig/ConfigDefinition.hpp"
25
26#include <memory>
27#include <string>
28#include <variant>
29
30namespace app {
31
39 struct Status {};
43 struct Migration {
44 std::string migratorName;
45 };
46
47 std::variant<Status, Migration> state;
48
54 static MigrateSubCmd
56 {
57 return MigrateSubCmd{Status{}};
58 }
59
66 static MigrateSubCmd
67 migration(std::string const& name)
68 {
69 return MigrateSubCmd{Migration{name}};
70 }
71};
72
77 std::string option_;
78 std::shared_ptr<migration::MigrationManagerInterface> migrationManager_;
79 MigrateSubCmd cmd_;
80 data::LedgerCache cache_;
81
82public:
90
96 int
97 run();
98
99private:
100 int
101 printStatus();
102
103 int
104 migrate(std::string const& name);
105};
106} // namespace app
The migration application class.
Definition MigrationApplication.hpp:76
MigratorApplication(util::config::ClioConfigDefinition const &config, MigrateSubCmd command)
Construct a new MigratorApplication object.
Definition MigrationApplication.cpp:39
int run()
Run the application.
Definition MigrationApplication.cpp:54
Cache for an entire ledger.
Definition LedgerCache.hpp:48
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:54
Run a migration.
Definition MigrationApplication.hpp:43
Check the status of the migrations.
Definition MigrationApplication.hpp:39
The command to run for migration framework.
Definition MigrationApplication.hpp:35
static MigrateSubCmd migration(std::string const &name)
Helper function to create a migration command.
Definition MigrationApplication.hpp:67
static MigrateSubCmd status()
Helper function to create a status command.
Definition MigrationApplication.hpp:55