Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions drivers/store/redis/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package redis

import (
"context"
"errors"
"fmt"
"strings"
"sync"
"sync/atomic"
"time"

"github.com/pkg/errors"
libredis "github.com/redis/go-redis/v9"

"github.com/ulule/limiter/v3"
"github.com/ulule/limiter/v3/drivers/store/common"
)
Expand Down Expand Up @@ -178,12 +178,12 @@ func (store *Store) loadLuaScripts(ctx context.Context) error {

luaIncrSHA, err := store.client.ScriptLoad(ctx, luaIncrScript).Result()
if err != nil {
return errors.Wrap(err, `failed to load "incr" lua script`)
return fmt.Errorf(`failed to load "incr" lua script: %w`, err)
}

luaPeekSHA, err := store.client.ScriptLoad(ctx, luaPeekScript).Result()
if err != nil {
return errors.Wrap(err, `failed to load "peek" lua script`)
return fmt.Errorf(`failed to load "peek" lua script: %w`, err)
}

store.luaIncrSHA = luaIncrSHA
Expand Down Expand Up @@ -237,7 +237,7 @@ func isLuaScriptGone(err error) bool {
func parseCountAndTTL(cmd *libredis.Cmd) (int64, int64, error) {
result, err := cmd.Result()
if err != nil {
return 0, 0, errors.Wrap(err, "an error has occurred with redis command")
return 0, 0, fmt.Errorf("an error has occurred with redis command: %w", err)
}

fields, ok := result.([]interface{})
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.17

require (
github.com/gin-gonic/gin v1.9.1
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.6.2
github.com/stretchr/testify v1.8.4
github.com/valyala/fasthttp v1.50.0
Expand Down
9 changes: 4 additions & 5 deletions rate.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package limiter

import (
"fmt"
"strconv"
"strings"
"time"

"github.com/pkg/errors"
)

// Rate is the rate.
Expand All @@ -21,7 +20,7 @@ func NewRateFromFormatted(formatted string) (Rate, error) {

values := strings.Split(formatted, "-")
if len(values) != 2 {
return rate, errors.Errorf("incorrect format '%s'", formatted)
return rate, fmt.Errorf("incorrect format '%s'", formatted)
}

periods := map[string]time.Duration{
Expand All @@ -35,12 +34,12 @@ func NewRateFromFormatted(formatted string) (Rate, error) {

p, ok := periods[period]
if !ok {
return rate, errors.Errorf("incorrect period '%s'", period)
return rate, fmt.Errorf("incorrect period '%s'", period)
}

l, err := strconv.ParseInt(limit, 10, 64)
if err != nil {
return rate, errors.Errorf("incorrect limit '%s'", limit)
return rate, fmt.Errorf("incorrect limit '%s'", limit)
}

rate = Rate{
Expand Down