summaryrefslogtreecommitdiff
path: root/vendor/github.com/ulule/limiter/v3/rate.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2025-03-09 17:47:56 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2025-03-10 01:59:49 +0100
commit3ac1ee16f377d31a0fb80c8dae28b6239ac4229e (patch)
treef61faa581feaaeaba2542b9f2b8234a590684413 /vendor/github.com/ulule/limiter/v3/rate.go
parent[chore] update URLs to forked source (diff)
downloadgotosocial-3ac1ee16f377d31a0fb80c8dae28b6239ac4229e.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/github.com/ulule/limiter/v3/rate.go')
-rw-r--r--vendor/github.com/ulule/limiter/v3/rate.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/vendor/github.com/ulule/limiter/v3/rate.go b/vendor/github.com/ulule/limiter/v3/rate.go
deleted file mode 100644
index 46f656dd1..000000000
--- a/vendor/github.com/ulule/limiter/v3/rate.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package limiter
-
-import (
- "strconv"
- "strings"
- "time"
-
- "github.com/pkg/errors"
-)
-
-// Rate is the rate.
-type Rate struct {
- Formatted string
- Period time.Duration
- Limit int64
-}
-
-// NewRateFromFormatted returns the rate from the formatted version.
-func NewRateFromFormatted(formatted string) (Rate, error) {
- rate := Rate{}
-
- values := strings.Split(formatted, "-")
- if len(values) != 2 {
- return rate, errors.Errorf("incorrect format '%s'", formatted)
- }
-
- periods := map[string]time.Duration{
- "S": time.Second, // Second
- "M": time.Minute, // Minute
- "H": time.Hour, // Hour
- "D": time.Hour * 24, // Day
- }
-
- limit, period := values[0], strings.ToUpper(values[1])
-
- p, ok := periods[period]
- if !ok {
- return rate, errors.Errorf("incorrect period '%s'", period)
- }
-
- l, err := strconv.ParseInt(limit, 10, 64)
- if err != nil {
- return rate, errors.Errorf("incorrect limit '%s'", limit)
- }
-
- rate = Rate{
- Formatted: formatted,
- Period: p,
- Limit: l,
- }
-
- return rate, nil
-}