business_flow 0.19.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 594752766329fcaa20e52b6b17f3a0b864fb893453055d24dd8596e0a3f5dac5
4
- data.tar.gz: c4c8a27b23c2bfdd63378d9a3da1f47e3f9c9f1e0b95eb7344575c30ef2651d0
3
+ metadata.gz: 0f141ad60cea86b41612d48091f29916ed512b95136f665a0e99fce1b9cddf60
4
+ data.tar.gz: b2342e16e41780165029b2605fe545ff940939903a85c7f749704e3af443a126
5
5
  SHA512:
6
- metadata.gz: 0ac739ddbf16363e5d6397be8720205187a9ccaa043a11b26e67ccc33f72f83d354c713d2359ffec27bb8a2c9cd93422922aee25aefcec424cc4bc3c5f76226c
7
- data.tar.gz: be38502bd0d953729bb48b723540dbc2288f5cd7eb56c5ef54e60854de6c2a4d185604f3d84c681c36906658058863d18ff86eb7a20144ee4a8d1d86fb033f40
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.2)
4
+ business_flow (0.19.3)
5
5
  activemodel (>= 4.2, < 8)
6
6
  activesupport (>= 4.2, < 8)
7
7
 
@@ -177,22 +177,38 @@ module BusinessFlow
177
177
  end
178
178
 
179
179
  def self.cleanup(lock, zk_connection)
180
- 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
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(:assert_failed, exc.message)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BusinessFlow
4
- VERSION = '0.19.2'.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.2
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-06 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