gcra 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4022887c88859ed2259a2e49450a62b1215b73b
4
- data.tar.gz: 8e5fe0ed06ca9012b455fb91571fa45d4c0f75ed
3
+ metadata.gz: 9b29ec6abd01bba124433e5e331f1935e9ed5edc
4
+ data.tar.gz: e44c984d0d02dd54f92959e9782d4b5d755f71b4
5
5
  SHA512:
6
- metadata.gz: e175732bc7e3d2f3e2fd0e9c4d75fbcaa80c8ad3786229ffdc22aff210f96d9a66ceacab0788a55eba4abcb0ac876c34d3654d25b8481ee1c28bfa643e62b2b9
7
- data.tar.gz: 4407751fe08bb38ad05c0af7fbaba7b9657d55cddd696a90a62a4b7550f1c57c8ddc5f8c94bd63ed78c6cfb405e51ea96a33dd9b8dba63b42383f77a8032bd51
6
+ metadata.gz: 3090609da18cda2a4807eff2e2fb7faf9a354dc996c159af0e42e1412448792196ba57151204cb96085e9a05417332e387c68cddb9a68fd0527a6123d99dd5de
7
+ data.tar.gz: f18cd4c996c23bef845942364f387101d4ed452e24fe289e39ff9d5333a3059d6cedb6218eeba7050ca1ddc41f7a0db3af46d8adc0cce8bd498be8d0b984d5bd
@@ -97,5 +97,30 @@ module GCRA
97
97
  "Failed to store updated rate limit data for key '#{key}' after #{MAX_ATTEMPTS} attempts"
98
98
  )
99
99
  end
100
+
101
+ # Overwrite the stored value for key to that of a bucket that has
102
+ # just overflowed, ignoring any existing stored data.
103
+ def mark_overflowed(key)
104
+ key = key.to_s unless key.is_a?(String)
105
+ i = 0
106
+ while i < MAX_ATTEMPTS
107
+ tat_from_store, now = @store.get_with_time(key)
108
+ new_value = now + @delay_variation_tolerance
109
+ ttl = @delay_variation_tolerance
110
+ updated = if tat_from_store.nil?
111
+ @store.set_if_not_exists_with_ttl(key, new_value, ttl)
112
+ else
113
+ @store.compare_and_set_with_ttl(key, tat_from_store, new_value, ttl)
114
+ end
115
+ if updated
116
+ return true
117
+ end
118
+ i += 1
119
+ end
120
+
121
+ raise StoreUpdateFailed.new(
122
+ "Failed to store updated rate limit data for key '#{key}' after #{MAX_ATTEMPTS} attempts"
123
+ )
124
+ end
100
125
  end
101
126
  end
@@ -1,3 +1,3 @@
1
1
  module GCRA
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Frister
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-27 00:00:00.000000000 Z
12
+ date: 2019-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec