summaryrefslogtreecommitdiff
path: root/vendor/github.com/ulule/limiter/v3/store.go
diff options
context:
space:
mode:
authorLibravatar nya1 <nya1git@imap.cc>2022-08-31 12:06:14 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-31 12:06:14 +0200
commitbee8458a2d12bdd42079fcb2c4ca88ebeafe305b (patch)
treec114acf28a460c1ebaa85965c89f2e7fb540eecc /vendor/github.com/ulule/limiter/v3/store.go
parent[feature] Sort follow requests, followers, and following by updated_at (#774) (diff)
downloadgotosocial-bee8458a2d12bdd42079fcb2c4ca88ebeafe305b.tar.xz
[feature] add rate limit middleware (#741)
* feat: add rate limit middleware * chore: update vendor dir * chore: update readme with new dependency * chore: add rate limit infos to swagger.md file * refactor: add ipv6 mask limiter option Add IPv6 CIDR /64 mask * refactor: increase rate limit to 1000 Address https://github.com/superseriousbusiness/gotosocial/pull/741#discussion_r945584800 Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/ulule/limiter/v3/store.go')
-rw-r--r--vendor/github.com/ulule/limiter/v3/store.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/github.com/ulule/limiter/v3/store.go b/vendor/github.com/ulule/limiter/v3/store.go
new file mode 100644
index 000000000..9fdb3aa04
--- /dev/null
+++ b/vendor/github.com/ulule/limiter/v3/store.go
@@ -0,0 +1,34 @@
+package limiter
+
+import (
+ "context"
+ "time"
+)
+
+// Store is the common interface for limiter stores.
+type Store interface {
+ // Get returns the limit for given identifier.
+ Get(ctx context.Context, key string, rate Rate) (Context, error)
+ // Peek returns the limit for given identifier, without modification on current values.
+ Peek(ctx context.Context, key string, rate Rate) (Context, error)
+ // Reset resets the limit to zero for given identifier.
+ Reset(ctx context.Context, key string, rate Rate) (Context, error)
+ // Increment increments the limit by given count & gives back the new limit for given identifier
+ Increment(ctx context.Context, key string, count int64, rate Rate) (Context, error)
+}
+
+// StoreOptions are options for store.
+type StoreOptions struct {
+ // Prefix is the prefix to use for the key.
+ Prefix string
+
+ // MaxRetry is the maximum number of retry under race conditions on redis store.
+ // Deprecated: this option is no longer required since all operations are atomic now.
+ MaxRetry int
+
+ // CleanUpInterval is the interval for cleanup (run garbage collection) on stale entries on memory store.
+ // Setting this to a low value will optimize memory consumption, but will likely
+ // reduce performance and increase lock contention.
+ // Setting this to a high value will maximum throughput, but will increase the memory footprint.
+ CleanUpInterval time.Duration
+}