From 89af7b2edb760300a695e95978308c167dc5864a Mon Sep 17 00:00:00 2001 From: Roman Kredentser Date: Mon, 23 Mar 2020 15:47:06 +0200 Subject: [PATCH] add key field to result --- gcra.go | 1 + rate.go | 3 +++ simple.go | 1 + 3 files changed, 5 insertions(+) diff --git a/gcra.go b/gcra.go index fce437a..c3cfc45 100644 --- a/gcra.go +++ b/gcra.go @@ -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), diff --git a/rate.go b/rate.go index 48b0c28..2aa0c3d 100644 --- a/rate.go +++ b/rate.go @@ -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 diff --git a/simple.go b/simple.go index 59f8c3e..55ad218 100644 --- a/simple.go +++ b/simple.go @@ -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),