business_flow 0.19.1 → 0.19.3
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/Gemfile.lock +1 -1
- data/lib/business_flow/cluster_lock.rb +29 -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
|
@@ -40,6 +40,14 @@ module BusinessFlow
|
|
|
40
40
|
raise
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def read_attribute_for_validation(key)
|
|
44
|
+
if key == :cluster_lock
|
|
45
|
+
ClassMethods.lock_name(self)
|
|
46
|
+
else
|
|
47
|
+
super(key)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
43
51
|
# DSL Methods
|
|
44
52
|
module ClassMethods
|
|
45
53
|
# Error raised when there is an internal issue with acquiring a lock.
|
|
@@ -169,22 +177,38 @@ module BusinessFlow
|
|
|
169
177
|
end
|
|
170
178
|
|
|
171
179
|
def self.cleanup(lock, zk_connection)
|
|
172
|
-
|
|
180
|
+
begin
|
|
181
|
+
lock.unlock if lock
|
|
182
|
+
rescue ZK::Exceptions::OperationTimeOut
|
|
183
|
+
# Just let the connection close handle this.
|
|
184
|
+
end
|
|
173
185
|
zk_connection.close! if zk_connection
|
|
174
186
|
end
|
|
175
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
|
+
|
|
176
202
|
def self.with_lock(flow, lock_info, &blk)
|
|
177
203
|
zk_connection, lock =
|
|
178
204
|
if !BusinessFlow::ClusterLock.disabled?
|
|
179
205
|
instrumented_acquire_lock(flow, lock_info)
|
|
180
206
|
end
|
|
181
207
|
yield lock_info
|
|
182
|
-
rescue ZK::Exceptions::LockAssertionFailedError => exc
|
|
208
|
+
rescue ZK::Exceptions::LockAssertionFailedError, ZK::Exceptions::OperationTimeOut => exc
|
|
183
209
|
# This would occur if we asserted a cluster lock while executing the flow.
|
|
184
210
|
# This will have set an error on the flow, so we can carry on.
|
|
185
|
-
raise LockFailure.new(
|
|
186
|
-
rescue ZK::Exceptions::OperationTimeOut
|
|
187
|
-
# Sometimes this happens. Just let the ensure block take care of everything
|
|
211
|
+
raise LockFailure.new(exception_to_error_type(exc), exc.message)
|
|
188
212
|
ensure
|
|
189
213
|
cleanup(lock, zk_connection)
|
|
190
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-
|
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|