mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 18:30:02 +08:00
chore: coding style (#4082)
This commit is contained in:
@@ -30,9 +30,8 @@ var (
|
||||
ErrUnknownCode = errors.New("unknown status code")
|
||||
|
||||
//go:embed periodscript.lua
|
||||
periodScript string
|
||||
|
||||
scriptPeriod = redis.NewScript(periodScript)
|
||||
periodLuaScript string
|
||||
periodScript = redis.NewScript(periodLuaScript)
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -73,7 +72,7 @@ func (h *PeriodLimit) Take(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.ScriptRunCtx(ctx, scriptPeriod, []string{h.keyPrefix + key}, []string{
|
||||
resp, err := h.limitStore.ScriptRunCtx(ctx, periodScript, []string{h.keyPrefix + key}, []string{
|
||||
strconv.Itoa(h.quota),
|
||||
strconv.Itoa(h.calcExpireSeconds()),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user