0AyanamiRei commented on code in PR #65420:
URL: https://github.com/apache/doris/pull/65420#discussion_r3597842977
##########
be/src/io/fs/s3_obj_storage_client.cpp:
##########
@@ -78,26 +78,36 @@ inline ::Aws::Client::AWSError<::Aws::S3::S3Errors>
s3_error_factory() {
}
template <typename Func>
-auto s3_rate_limit(doris::S3RateLimitType op, Func callback) ->
decltype(callback()) {
+auto s3_rate_limit(bool is_internal_bucket, doris::S3RateLimitType op, Func
callback)
+ -> decltype(callback()) {
using T = decltype(callback());
- if (!doris::config::enable_s3_rate_limiter) {
- return callback();
- }
- auto sleep_duration = doris::apply_s3_rate_limit(op);
- if (sleep_duration < 0) {
+ if (!doris::acquire_s3_qps_rate_limit(is_internal_bucket, op)) {
return T(s3_error_factory());
}
return callback();
}
template <typename Func>
-auto s3_get_rate_limit(Func callback) -> decltype(callback()) {
- return s3_rate_limit(doris::S3RateLimitType::GET, std::move(callback));
+auto s3_get_rate_limit(bool is_internal_bucket, Func callback) ->
decltype(callback()) {
+ return s3_rate_limit(is_internal_bucket, doris::S3RateLimitType::GET,
std::move(callback));
}
template <typename Func>
-auto s3_put_rate_limit(Func callback) -> decltype(callback()) {
- return s3_rate_limit(doris::S3RateLimitType::PUT, std::move(callback));
+auto s3_put_rate_limit(bool is_internal_bucket, Func callback) ->
decltype(callback()) {
+ return s3_rate_limit(is_internal_bucket, doris::S3RateLimitType::PUT,
std::move(callback));
+}
+
+template <typename Request>
+void set_s3_bytes_rate_limit_handler(Request& request, bool is_internal_bucket,
+ doris::S3RateLimitType type, size_t
bytes) {
+ request.SetRequestSignedHandler([is_internal_bucket, type,
+ bytes](const Aws::Http::HttpRequest&) {
+ if (!doris::acquire_s3_bytes_rate_limit(is_internal_bucket, type,
bytes)) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]