business_flow 0.19.2 → 0.19.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/business_flow/cluster_lock.rb +21 -5
- data/lib/business_flow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f141ad60cea86b41612d48091f29916ed512b95136f665a0e99fce1b9cddf60
|
4
|
+
data.tar.gz: b2342e16e41780165029b2605fe545ff940939903a85c7f749704e3af443a126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b48a9c480de3bbb78c0fe1f2bdadb7b05e8f93068eac08d5b9aa21999d5c6f54b97febee0366de7c49ea4dafd8a3e87d362a6d70e0e2dc3997ee0a25eda1deb2
|
7
|
+
data.tar.gz: cef0b142c7f352dc83cf786a5a2df98a37101c58f8b7c75fda2fa0cc113211531657aaeb7813f88b8738ea6bd8d7ce49e2b9aeb00adf88766f31b16e8ec7012b
|
data/Gemfile.lock
CHANGED
@@ -177,22 +177,38 @@ module BusinessFlow
|
|
177
177
|
end
|
178
178
|
|
179
179
|
def self.cleanup(lock, zk_connection)
|
180
|
-
|
180
|
+
begin
|
181
|
+
lock.unlock if lock
|
182
|
+
rescue ZK::Exceptions::OperationTimeOut
|
183
|
+
# Just let the connection close handle this.
|
184
|
+
end
|
181
185
|
zk_connection.close! if zk_connection
|
182
186
|
end
|
183
187
|
|
188
|
+
# :reek:ControlParameter
|
189
|
+
# I'm using a case statement instead of a hash in a constant to ensure that this
|
190
|
+
# doesn't throw exceptions if this file is required before zookeeper is.
|
191
|
+
def self.exception_to_error_type(exc)
|
192
|
+
case exc
|
193
|
+
when ZK::Exceptions::LockAssertionFailedError
|
194
|
+
:assert_failed
|
195
|
+
when ZK::Exceptions::OperationTimeOut
|
196
|
+
:zookeeper_timeout
|
197
|
+
else
|
198
|
+
:unknown_failure
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
184
202
|
def self.with_lock(flow, lock_info, &blk)
|
185
203
|
zk_connection, lock =
|
186
204
|
if !BusinessFlow::ClusterLock.disabled?
|
187
205
|
instrumented_acquire_lock(flow, lock_info)
|
188
206
|
end
|
189
207
|
yield lock_info
|
190
|
-
rescue ZK::Exceptions::LockAssertionFailedError => exc
|
208
|
+
rescue ZK::Exceptions::LockAssertionFailedError, ZK::Exceptions::OperationTimeOut => exc
|
191
209
|
# This would occur if we asserted a cluster lock while executing the flow.
|
192
210
|
# This will have set an error on the flow, so we can carry on.
|
193
|
-
raise LockFailure.new(
|
194
|
-
rescue ZK::Exceptions::OperationTimeOut
|
195
|
-
# Sometimes this happens. Just let the ensure block take care of everything
|
211
|
+
raise LockFailure.new(exception_to_error_type(exc), exc.message)
|
196
212
|
ensure
|
197
213
|
cleanup(lock, zk_connection)
|
198
214
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Scarborough
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|