-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This updates our remote IO HTTP handler to check the status code of the response. If we get a 50x error, we'll retry up to some limit. Closes #601 Authors: - Tom Augspurger (https://github.com/TomAugspurger) - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Mads R. B. Kristensen (https://github.com/madsbk) - Bradley Dice (https://github.com/bdice) Approvers: - Tianyu Liu (https://github.com/kingcrimsontianyu) - Mads R. B. Kristensen (https://github.com/madsbk) - Bradley Dice (https://github.com/bdice) URL: #603
- Loading branch information
1 parent
637cac5
commit 25051e6
Showing
21 changed files
with
617 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace kvikio { | ||
namespace detail { | ||
/** | ||
* @brief Parse a string of comma-separated string of HTTP status codes. | ||
* | ||
* @param env_var_name The environment variable holding the string. | ||
* Used to report errors. | ||
* @param status_codes The comma-separated string of HTTP status | ||
* codes. Each code should be a 3-digit integer. | ||
* | ||
* @return The vector with the parsed, integer HTTP status codes. | ||
*/ | ||
std::vector<int> parse_http_status_codes(std::string_view env_var_name, | ||
std::string const& status_codes); | ||
} // namespace detail | ||
|
||
} // namespace kvikio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cstddef> | ||
#include <cstdlib> | ||
#include <regex> | ||
#include <sstream> | ||
#include <stdexcept> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace kvikio { | ||
|
||
namespace detail { | ||
std::vector<int> parse_http_status_codes(std::string_view env_var_name, | ||
std::string const& status_codes) | ||
{ | ||
// Ensure `status_codes` consists only of 3-digit integers separated by commas, allowing spaces. | ||
std::regex const check_pattern(R"(^\s*\d{3}\s*(\s*,\s*\d{3}\s*)*$)"); | ||
if (!std::regex_match(status_codes, check_pattern)) { | ||
throw std::invalid_argument(std::string{env_var_name} + | ||
": invalid format, expected comma-separated integers."); | ||
} | ||
|
||
// Match every integer in `status_codes`. | ||
std::regex const number_pattern(R"(\d+)"); | ||
|
||
// For each match, we push_back `std::stoi(match.str())` into `ret`. | ||
std::vector<int> ret; | ||
std::transform(std::sregex_iterator(status_codes.begin(), status_codes.end(), number_pattern), | ||
std::sregex_iterator(), | ||
std::back_inserter(ret), | ||
[](std::smatch const& match) -> int { return std::stoi(match.str()); }); | ||
return ret; | ||
} | ||
|
||
} // namespace detail | ||
|
||
} // namespace kvikio |
Oops, something went wrong.