Skip to content

Commit

Permalink
rate_limit: Add time unit month and year (#24070)
Browse files Browse the repository at this point in the history
Signed-off-by: tyxia <tyxia@google.com>
  • Loading branch information
tyxia authored Nov 21, 2022
1 parent b5e3ec9 commit 8a26244
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/envoy/service/ratelimit/v3/rls.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ message RateLimitResponse {

// The time unit representing a day.
DAY = 4;

// The time unit representing a month.
MONTH = 5;

// The time unit representing a year.
YEAR = 6;
}

// A name or description of this limit.
Expand Down
3 changes: 3 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ minor_behavior_changes:
- area: oauth2
change: |
Requests which match the passthrough header now have their own metric ``oauth_passthrough`` and aren't included in ``oauth_success`` anymore.
- area: rate_limit
change: |
add ``MONTH`` and ``YEAR`` to the unit of time for rate limit.
bug_fixes:
# *Changes expected to improve the state of the world and are unlikely to have negative effects*
Expand Down
4 changes: 4 additions & 0 deletions source/extensions/filters/http/ratelimit/ratelimit_headers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ uint32_t XRateLimitHeaderUtils::convertRateLimitUnit(
return 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::DAY:
return 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::MONTH:
return 30 * 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::YEAR:
return 365 * 24 * 60 * 60;
case envoy::service::ratelimit::v3::RateLimitResponse::RateLimit::UNKNOWN:
default:
return 0;
Expand Down

0 comments on commit 8a26244

Please sign in to comment.