From db9a1f3e276678be9fed5437f24b172ed2199f5c Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 11 Jun 2022 12:34:10 +0800 Subject: [PATCH] chore: rename methods (#1998) --- core/limit/periodlimit.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/limit/periodlimit.go b/core/limit/periodlimit.go index 20ad93fb..5250878a 100644 --- a/core/limit/periodlimit.go +++ b/core/limit/periodlimit.go @@ -75,11 +75,11 @@ func NewPeriodLimit(period, quota int, limitStore *redis.Redis, keyPrefix string // Take requests a permit, it returns the permit state. func (h *PeriodLimit) Take(key string) (int, error) { - return h.TakeWithContext(context.Background(), key) + return h.TakeCtx(context.Background(), key) } -// TakeWithContext requests a permit with context, it returns the permit state. -func (h *PeriodLimit) TakeWithContext(ctx context.Context, key string) (int, error) { +// TakeCtx requests a permit with context, it returns the permit state. +func (h *PeriodLimit) TakeCtx(ctx context.Context, key string) (int, error) { resp, err := h.limitStore.EvalCtx(ctx, periodScript, []string{h.keyPrefix + key}, []string{ strconv.Itoa(h.quota), strconv.Itoa(h.calcExpireSeconds()),