Skip to content

Commit

Permalink
add key field to result
Browse files Browse the repository at this point in the history
  • Loading branch information
Shareed2k committed Mar 23, 2020
1 parent 917bb18 commit 89af7b2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcra.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (c *gcra) AllowN(n int) (*Result, error) {

res := &Result{
Limit: limit,
Key: c.key,
Allowed: values[0].(int64) == 0,
Remaining: values[1].(int64),
RetryAfter: dur(retryAfter),
Expand Down
3 changes: 3 additions & 0 deletions rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type (
// Limit is the limit that was used to obtain this result.
Limit *Limit

// Key is the key of limit
Key string

// Allowed reports whether event may happen at time now.
Allowed bool

Expand Down
1 change: 1 addition & 0 deletions simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (c *simple) Allow() (r *Result, err error) {

return &Result{
Limit: limit,
Key: c.key,
Allowed: values[0].(int64) == 1,
Remaining: values[1].(int64),
RetryAfter: dur(retryAfter),
Expand Down

0 comments on commit 89af7b2

Please sign in to comment.