new_build_system (#18)
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
Reviewed-on: #18
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#include "utils/common.hpp"
|
||||
|
||||
#include "utils/path.hpp"
|
||||
#include "utils/error.hpp"
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace repertory::utils {
|
||||
@@ -67,7 +67,7 @@ auto compare_version_strings(std::wstring_view version1,
|
||||
|
||||
#if defined(PROJECT_ENABLE_STDUUID)
|
||||
auto create_uuid_string() -> std::string {
|
||||
std::random_device random_device;
|
||||
std::random_device random_device{};
|
||||
auto seed_data = std::array<int, std::mt19937::state_size>{};
|
||||
std::generate(std::begin(seed_data), std::end(seed_data),
|
||||
std::ref(random_device));
|
||||
@@ -83,7 +83,6 @@ auto create_uuid_wstring() -> std::wstring {
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_STDUUID)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
auto generate_random_string(std::size_t length) -> std::string {
|
||||
std::string ret;
|
||||
if (length == 0U) {
|
||||
@@ -98,9 +97,7 @@ auto generate_random_string(std::size_t length) -> std::string {
|
||||
generate_random_between(97U, 255U),
|
||||
};
|
||||
ch = static_cast<char>(
|
||||
random_list.at(repertory::utils::generate_random_between(0U, 2U)) %
|
||||
74U +
|
||||
48U);
|
||||
random_list.at(generate_random_between(0U, 2U)) % 74U + 48U);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -109,7 +106,6 @@ auto generate_random_string(std::size_t length) -> std::string {
|
||||
auto generate_random_wstring(std::size_t length) -> std::wstring {
|
||||
return utils::string::from_utf8(generate_random_string(length));
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
auto get_environment_variable(std::string_view variable) -> std::string {
|
||||
static std::mutex mtx{};
|
||||
@@ -154,4 +150,27 @@ auto get_next_available_port(std::uint16_t first_port,
|
||||
return not error_code;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_BOOST)
|
||||
|
||||
auto retry_action(retryable_action_t action, std::size_t retry_count,
|
||||
std::chrono::milliseconds retry_wait) -> bool {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
try {
|
||||
for (std::size_t idx = 0U; idx < retry_count; ++idx) {
|
||||
if (action()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(retry_wait);
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
} catch (...) {
|
||||
utils::error::handle_exception(function_name);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace repertory::utils
|
||||
|
Reference in New Issue
Block a user