istox 0.2.14 → 0.2.15
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dcf442cd8dd270827e55bcc957f9fa2862c04d390d5c1582097fae1638e673a
|
4
|
+
data.tar.gz: aed8de1bf449846ef9697364897ac0895215362c5413f444538858fd4cdf9a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b97430930b5d79fa173ea9720ffbb479a8313857d6206f9c114190f6a2ce50b770685d395cb7e12456351829b937943b00d98df87cbfd8eca87c241bb631ba
|
7
|
+
data.tar.gz: eb27d9d006914505ef2bb16cda935a57fb03481c6e3035191bb7e888eb417afcde41a0893e511f72425b8860364546e3ae5fedb91ef66e6fb093467a88574af1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.2.
|
4
|
+
istox (0.2.15)
|
5
5
|
amazing_print
|
6
6
|
awesome_print
|
7
7
|
aws-sdk-sns (~> 1)
|
@@ -134,7 +134,7 @@ GEM
|
|
134
134
|
ffi (1.15.3)
|
135
135
|
globalid (0.4.2)
|
136
136
|
activesupport (>= 4.2.0)
|
137
|
-
google-protobuf (3.17.3)
|
137
|
+
google-protobuf (3.17.3-universal-darwin)
|
138
138
|
googleapis-common-protos-types (1.1.0)
|
139
139
|
google-protobuf (~> 3.14)
|
140
140
|
graphlient (0.5.0)
|
@@ -145,7 +145,7 @@ GEM
|
|
145
145
|
graphql-client (0.16.0)
|
146
146
|
activesupport (>= 3.0)
|
147
147
|
graphql (~> 1.8)
|
148
|
-
grpc (1.38.0)
|
148
|
+
grpc (1.38.0-universal-darwin)
|
149
149
|
google-protobuf (~> 3.15)
|
150
150
|
googleapis-common-protos-types (~> 1.0)
|
151
151
|
grpc-tools (1.38.0)
|
@@ -44,6 +44,9 @@ module Istox
|
|
44
44
|
## for request there we need a lock to prevent there is not duplicate request exist for single model
|
45
45
|
::Istox::RaceConditionHelper.acquire!(key) if is_request
|
46
46
|
|
47
|
+
## validate the request, this validation is overridable by inherited class
|
48
|
+
receipt.validate_request!(model.class.name, model.id) if is_request
|
49
|
+
|
47
50
|
# delete the previous existing blockchain receipts
|
48
51
|
klass.where(resource_name: model.class.name, resource_id: model.id).destroy_all
|
49
52
|
|
@@ -10,12 +10,26 @@ module Istox
|
|
10
10
|
def acquire(key, expired_seconds: 20)
|
11
11
|
result = request_redis.set('race-condition||' + key.to_s, 'EMPTY', nx: true, ex: expired_seconds.to_i.seconds)
|
12
12
|
|
13
|
+
log.info("Acquiring lock for key: #{key}, expired in #{expired_seconds} seconds, result: #{result}")
|
14
|
+
|
13
15
|
# if result false means the key already exist
|
14
|
-
result
|
16
|
+
[true, 1].include?(result)
|
15
17
|
end
|
16
18
|
|
17
19
|
def release(key)
|
18
20
|
request_redis.del('race-condition||' + key.to_s)
|
21
|
+
|
22
|
+
log.info("Releasing lock for key: #{key}")
|
23
|
+
end
|
24
|
+
|
25
|
+
### lock with block
|
26
|
+
def lock!(key, expired_seconds: 20)
|
27
|
+
acquire!(key, expired_seconds: expired_seconds)
|
28
|
+
yield
|
29
|
+
release(key)
|
30
|
+
rescue StandardError => e
|
31
|
+
release(key)
|
32
|
+
raise e
|
19
33
|
end
|
20
34
|
|
21
35
|
def request_redis
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|