gitlab-labkit 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/labkit/rate_limit/evaluator.rb +6 -4
- data/lib/labkit/rate_limit.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7177b8f9210f24958a14c92f17ad35cc8d4ad7732e04a9407569e865ef2bf364
|
|
4
|
+
data.tar.gz: 688c6dd7b7c1a8c1062a1e17c534fa833f86053aff8945ab4d296c2223784711
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b54fe16d5c1cfe12c704a4e84cdea8dece8155dcaa04132c9e52442bec03e6338f6a4bcb065aa87931aa2fedcbd2ecb5ecec390b00d110267ee54e95a5c694c
|
|
7
|
+
data.tar.gz: 8abc6a48c3f1b138a84f8502e5c4300bec5f05f98b0c8defb4280d12b1d424f70cf64e0afe3cc344ce61ceae145e9aaf11f252d9611da1e5c6a1f25aa37fe867
|
|
@@ -92,10 +92,12 @@ module Labkit
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def incr_with_ttl(redis_key, period)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
@redis.with do |conn|
|
|
96
|
+
count = conn.incr(redis_key)
|
|
97
|
+
# Set expiry only on first write to avoid resetting TTL on each call
|
|
98
|
+
conn.expire(redis_key, period) if count == 1
|
|
99
|
+
count
|
|
100
|
+
end
|
|
99
101
|
end
|
|
100
102
|
|
|
101
103
|
def log_error(error, identifier)
|
data/lib/labkit/rate_limit.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Labkit
|
|
|
6
6
|
#
|
|
7
7
|
# @example Configuration (e.g. in a Rails initializer)
|
|
8
8
|
# Labkit::RateLimit.configure do |c|
|
|
9
|
-
# c.redis = Redis.
|
|
9
|
+
# c.redis = ConnectionPool.new { Redis.new } # must respond to .with { |conn| }
|
|
10
10
|
# c.logger = Labkit::Logging::JsonLogger.new($stdout)
|
|
11
11
|
# end
|
|
12
12
|
#
|