Skip to content

Commit

Permalink
enable rate limit for month and year (#743)
Browse files Browse the repository at this point in the history
Signed-off-by: Rico Pahlisch <pahli88@googlemail.com>
Signed-off-by: Rico Pahlisch <rico.pahlisch@grayc.de>
  • Loading branch information
rpahli authored Dec 6, 2024
1 parent 1818d41 commit d36a71b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/ratelimit/config/ratelimit/v3/rls_conf.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,10 @@ enum RateLimitUnit {

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

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

// The time unit representing a year.
YEAR = 6;
}
4 changes: 4 additions & 0 deletions src/utils/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func UnitToDivider(unit pb.RateLimitResponse_RateLimit_Unit) int64 {
return 60 * 60
case pb.RateLimitResponse_RateLimit_DAY:
return 60 * 60 * 24
case pb.RateLimitResponse_RateLimit_MONTH:
return 60 * 60 * 24 * 30
case pb.RateLimitResponse_RateLimit_YEAR:
return 60 * 60 * 24 * 356
}

panic("should not get here")
Expand Down

0 comments on commit d36a71b

Please sign in to comment.