business_flow 0.19.2 → 0.19.4

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: 307a7eda1932f6d130f00e092df7a21cb2a33b011e83673558fdcf0fcbddb197
4
+ data.tar.gz: 6397d9e3d64e63892323e1d17489aab5d8c65a81dd38723cb7160278c2cbb41b
5
5
  SHA512:
6
- metadata.gz: 0ac739ddbf16363e5d6397be8720205187a9ccaa043a11b26e67ccc33f72f83d354c713d2359ffec27bb8a2c9cd93422922aee25aefcec424cc4bc3c5f76226c
7
- data.tar.gz: be38502bd0d953729bb48b723540dbc2288f5cd7eb56c5ef54e60854de6c2a4d185604f3d84c681c36906658058863d18ff86eb7a20144ee4a8d1d86fb033f40
6
+ metadata.gz: 73d2958f6aabc69cb04f442a317c1b4cf561f305cbc2641e88a623d003d46dd496d69d62b240fba1d9e0567f4297ed6fa80ef935ea832629563ce31205b419c3
7
+ data.tar.gz: 15db0becd4c584ef9dd926eb02d4ffe34b30b184ffdbd484fc44b8264e25c1a856b8ea41049ba3f005a342d438dd16e1a75a32842c5e9e1c4d00a8c668eeec88
data/Gemfile.lock CHANGED
@@ -1,29 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.19.2)
4
+ business_flow (0.19.4)
5
5
  activemodel (>= 4.2, < 8)
6
6
  activesupport (>= 4.2, < 8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (7.0.4)
12
- activesupport (= 7.0.4)
13
- activesupport (7.0.4)
11
+ activemodel (7.1.3)
12
+ activesupport (= 7.1.3)
13
+ activesupport (7.1.3)
14
+ base64
15
+ bigdecimal
14
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ connection_pool (>= 2.2.5)
18
+ drb
15
19
  i18n (>= 1.6, < 2)
16
20
  minitest (>= 5.1)
21
+ mutex_m
17
22
  tzinfo (~> 2.0)
18
23
  ast (2.4.2)
19
- concurrent-ruby (1.1.10)
24
+ base64 (0.2.0)
25
+ bigdecimal (3.1.6)
26
+ concurrent-ruby (1.2.3)
27
+ connection_pool (2.4.1)
20
28
  diff-lcs (1.5.0)
21
29
  docile (1.4.0)
22
- i18n (1.12.0)
30
+ drb (2.2.0)
31
+ ruby2_keywords
32
+ i18n (1.14.1)
23
33
  concurrent-ruby (~> 1.0)
24
34
  jaro_winkler (1.5.4)
25
35
  kwalify (0.7.2)
26
- minitest (5.16.3)
36
+ minitest (5.21.2)
37
+ mutex_m (0.2.0)
27
38
  parallel (1.22.1)
28
39
  parser (3.2.2.1)
29
40
  ast (~> 2.4.1)
@@ -57,6 +68,7 @@ GEM
57
68
  rubocop-rspec (1.24.0)
58
69
  rubocop (>= 0.53.0)
59
70
  ruby-progressbar (1.11.0)
71
+ ruby2_keywords (0.0.5)
60
72
  simplecov (0.22.0)
61
73
  docile (~> 1.1)
62
74
  simplecov-html (~> 0.11)
@@ -64,7 +76,7 @@ GEM
64
76
  simplecov-html (0.12.3)
65
77
  simplecov_json_formatter (0.1.4)
66
78
  timecop (0.9.6)
67
- tzinfo (2.0.5)
79
+ tzinfo (2.0.6)
68
80
  concurrent-ruby (~> 1.0)
69
81
  unicode-display_width (1.5.0)
70
82
 
@@ -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
@@ -56,11 +56,12 @@ module BusinessFlow
56
56
  # without having to check for whether or not the wants can be executed.
57
57
  #
58
58
  # :reek:NilCheck This is one of the places where we eliminate nil.
59
- def lookup(field, by:, with:)
59
+ # :reek:LongParameterList Deal with it
60
+ def lookup(field, by:, with:, inputs: nil, output: nil)
60
61
  by = Array.wrap(by)
61
62
  optional(*by)
62
63
  wants field, with, unless: -> { by.any? { |input| send(input).nil? } },
63
- default_output: field
64
+ default_output: field, inputs: inputs, output: output
64
65
  end
65
66
 
66
67
  # Allows a field to be retrieved from the initialiaztion parameters
@@ -160,10 +160,9 @@ module BusinessFlow
160
160
 
161
161
  def to_unless(cond)
162
162
  if_stmt = Callable.new(cond)
163
- unless_stmt = proc do |instance, input|
163
+ proc do |instance, input|
164
164
  !if_stmt.call(instance, input)
165
165
  end
166
- Callable.new(unless_stmt)
167
166
  end
168
167
  end
169
168
 
@@ -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.4'.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.4
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: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel