business_flow 0.19.1 → 0.19.3

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: b3cbbc4f9a0eba68f3056378a62625b0b855957945fb45392fe3101455aa3df3
4
- data.tar.gz: 4b47a1c7479257c75814abdaaa023e9cc58c01e169eacfd95276c26441c64203
3
+ metadata.gz: 0f141ad60cea86b41612d48091f29916ed512b95136f665a0e99fce1b9cddf60
4
+ data.tar.gz: b2342e16e41780165029b2605fe545ff940939903a85c7f749704e3af443a126
5
5
  SHA512:
6
- metadata.gz: 15aa3e482853c9f9022729f3e44e4f4e566695b23393339c3fb11915127c0003992de7fb04e4515725e99fbb2dddfe6bd8c1d9dcbb8dc7ee82c523a956181b3b
7
- data.tar.gz: 947c46bdd62b88e8a5d588d3258a8df4f0820b0dd8ba408329fd6b4dc3acf16019465e242bbb1a0ebb0806af1f367813fc1c5735e66c52e15ca4a330e9b0cf49
6
+ metadata.gz: b48a9c480de3bbb78c0fe1f2bdadb7b05e8f93068eac08d5b9aa21999d5c6f54b97febee0366de7c49ea4dafd8a3e87d362a6d70e0e2dc3997ee0a25eda1deb2
7
+ data.tar.gz: cef0b142c7f352dc83cf786a5a2df98a37101c58f8b7c75fda2fa0cc113211531657aaeb7813f88b8738ea6bd8d7ce49e2b9aeb00adf88766f31b16e8ec7012b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.19.1)
4
+ business_flow (0.19.3)
5
5
  activemodel (>= 4.2, < 8)
6
6
  activesupport (>= 4.2, < 8)
7
7
 
@@ -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
- lock.unlock if lock
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(:assert_failed, exc.message)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BusinessFlow
4
- VERSION = '0.19.1'.freeze
4
+ VERSION = '0.19.3'.freeze
5
5
  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.1
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-05-19 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel