From cac7f567bf0ca729f64b9f963c341cac5381e062 Mon Sep 17 00:00:00 2001 From: Seyed Ali Kamali Pargoo Date: Sun, 9 Jun 2024 21:44:08 +0330 Subject: [PATCH 1/2] Adds Per day limit --- rate.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rate.go b/rate.go index 1cfc36e..6dbad8e 100644 --- a/rate.go +++ b/rate.go @@ -72,6 +72,14 @@ func PerHour(rate int) Limit { } } +func PerDay(rate int) Limit { + return Limit{ + Rate: rate, + Period: time.Hour * 24, + Burst: rate, + } +} + // ------------------------------------------------------------------------------ // Limiter controls how frequently events are allowed to happen. From 5a2a63410490cfecd8b2b5a9bd5fae41883dadb5 Mon Sep 17 00:00:00 2001 From: Seyed Ali Kamali Pargoo Date: Sun, 9 Jun 2024 21:45:12 +0330 Subject: [PATCH 2/2] Adds Custom limit --- rate.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rate.go b/rate.go index 6dbad8e..77cd876 100644 --- a/rate.go +++ b/rate.go @@ -80,6 +80,14 @@ func PerDay(rate int) Limit { } } +func Per(rate int, period time.Duration) Limit { + return Limit{ + Rate: rate, + Period: period, + Burst: rate, + } +} + // ------------------------------------------------------------------------------ // Limiter controls how frequently events are allowed to happen.