Skip to content

Commit 5f72b36

Browse files
committed
Add Limit to Result
1 parent 78a11c8 commit 5f72b36

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func (l *Limiter) AllowN(key string, limit *Limit, n int) (*Result, error) {
8686
}
8787

8888
res := &Result{
89+
Limit: limit,
8990
Allowed: values[0].(int64) == 0,
9091
Remaining: int(values[1].(int64)),
9192
RetryAfter: dur(retryAfter),
@@ -102,6 +103,9 @@ func dur(f float64) time.Duration {
102103
}
103104

104105
type Result struct {
106+
// Limit is the limit that was used to obtain this result.
107+
Limit *Limit
108+
105109
// Allowed reports whether event may happen at time now.
106110
Allowed bool
107111

0 commit comments

Comments
 (0)