idempotent-request 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: d52f16d55268a056fc1a8239d3112fcc4ef621442e78f5f4100a6093d3279711
4
- data.tar.gz: fd9bd7e9290369d1ec2e583eea23bd3ac41d2b1b143cff1faebcc3c65ab17565
3
+ metadata.gz: 5cebd804243368dfc14a6199bd3d51f40ebaa149cf697e1793a63f6559f2de23
4
+ data.tar.gz: 0a9082b74528e9fb15a5fe8981755d004cc325d9a8fa9373acd94352b62335a6
5
5
  SHA512:
6
- metadata.gz: 55daca8c55cc835f24a72c94e72636c3935e27d223238c34fec6d5795fd7b1ec5e6bda6da277783ba3f97af68451356583cbffc02b65791cd6bee2518f4f5ce3
7
- data.tar.gz: 04cf35af5be08d455d9aca35f5a41c7924b8d3934b47dec10fb8c0eb5a89555279d5e3d601b02d7ceb835781ef3598c0c442668862bae16c43418290fce81158
6
+ metadata.gz: f5917e4b4f23d74fa2bfcc4b5a2faef9c140a3b77f8b69c63b8d0cac10dab638bbe3b04d842b0a6a8ec54350251717f72a41004078d30d3c53bf7f229def6188
7
+ data.tar.gz: 9bb5f2d94fc04a58fcd6118312622eaa7211c189461a4dd28491b0b433b8a90b22a7fcfa9c21a499239e76cf59cea6f8aab4a05198fd2cc808c8d7b441d4e21d
@@ -12,6 +12,10 @@ module IdempotentRequest
12
12
  setnx_with_expiration(lock_key(key), true)
13
13
  end
14
14
 
15
+ def unlock(key)
16
+ redis.del(lock_key(key))
17
+ end
18
+
15
19
  def read(key)
16
20
  redis.get(namespaced_key(key))
17
21
  end
@@ -12,6 +12,10 @@ module IdempotentRequest
12
12
  storage.lock(key)
13
13
  end
14
14
 
15
+ def unlock
16
+ storage.unlock(key)
17
+ end
18
+
15
19
  def read
16
20
  status, headers, response = parse_data(storage.read(key)).values
17
21
 
@@ -23,8 +27,13 @@ module IdempotentRequest
23
27
  def write(*data)
24
28
  status, headers, response = data
25
29
  response = response.body if response.respond_to?(:body)
26
- return data unless (200..226).include?(status)
27
- storage.write(key, payload(status, headers, response))
30
+
31
+ if (200..226).cover?(status)
32
+ storage.write(key, payload(status, headers, response))
33
+ else
34
+ unlock
35
+ end
36
+
28
37
  data
29
38
  end
30
39
 
@@ -1,3 +1,3 @@
1
1
  module IdempotentRequest
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idempotent-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Zakharov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-29 00:00:00.000000000 Z
11
+ date: 2018-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack