feat: Migration framework (#1768)

This PR implemented the migration framework, which contains the command
line interface to execute migration and helps to migrate data easily.
Please read README.md for more information about this framework.
This commit is contained in:
cyan317
2024-12-17 14:50:51 +00:00
committed by GitHub
parent 15a441b084
commit 8dc7f16ef1
69 changed files with 4395 additions and 17 deletions

View File

@@ -21,6 +21,8 @@
#include <algorithm>
#include <array>
#include <cstddef>
#include <string_view>
#include <type_traits>
namespace util {
@@ -46,4 +48,22 @@ hasNoDuplicates(auto&&... values)
return (std::unique(std::begin(store), end) == end);
}
/**
* @brief Checks that the list of given type contains no duplicates
*
* @tparam Types The types to check
* @returns true if no duplicates exist; false otherwise
*/
template <typename... Types>
constexpr bool
hasNoDuplicateNames()
{
constexpr std::array<std::string_view, sizeof...(Types)> names = {Types::name...};
return !std::ranges::any_of(names, [&](std::string_view const& name1) {
return std::ranges::any_of(names, [&](std::string_view const& name2) {
return &name1 != &name2 && name1 == name2; // Ensure different elements are compared
});
});
}
} // namespace util

View File

@@ -169,7 +169,7 @@ class Logger final {
};
public:
static constexpr std::array<char const*, 7> CHANNELS = {
static constexpr std::array<char const*, 8> CHANNELS = {
"General",
"WebServer",
"Backend",
@@ -177,6 +177,7 @@ public:
"ETL",
"Subscriptions",
"Performance",
"Migration",
};
/**

View File

@@ -380,7 +380,11 @@ static ClioConfigDefinition ClioConfig = ClioConfigDefinition{
{"api_version.min",
ConfigValue{ConfigType::Integer}.defaultValue(rpc::API_VERSION_MIN).withConstraint(validateApiVersion)},
{"api_version.max",
ConfigValue{ConfigType::Integer}.defaultValue(rpc::API_VERSION_MAX).withConstraint(validateApiVersion)}}
ConfigValue{ConfigType::Integer}.defaultValue(rpc::API_VERSION_MAX).withConstraint(validateApiVersion)},
{"migration.full_scan_threads", ConfigValue{ConfigType::Integer}.defaultValue(2).withConstraint(validateUint32)},
{"migration.full_scan_jobs", ConfigValue{ConfigType::Integer}.defaultValue(4).withConstraint(validateUint32)},
{"migration.cursors_per_job", ConfigValue{ConfigType::Integer}.defaultValue(100).withConstraint(validateUint32)}},
};
} // namespace util::config

View File

@@ -163,7 +163,10 @@ private:
KV{.key = "ssl_key_file", .value = "Path to the SSL key file."},
KV{.key = "api_version.default", .value = "Default API version Clio will run on."},
KV{.key = "api_version.min", .value = "Minimum API version."},
KV{.key = "api_version.max", .value = "Maximum API version."}
KV{.key = "api_version.max", .value = "Maximum API version."},
KV{.key = "migration.full_scan_threads", .value = "The number of threads used to scan table."},
KV{.key = "migration.full_scan_jobs", .value = "The number of coroutines used to scan table."},
KV{.key = "migration.cursors_per_job", .value = "The number of cursors each coroutine will scan."}
};
};