faktory_worker_ruby 1.2.0 → 1.3.0

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: 57f98beb553cb8d38e36d45b1721c15446201a30db101827d277ef7f3b9fb542
4
- data.tar.gz: a0d82206d826d345bdcde2271ccf300c8af2ccb7ce4c2140900f00b0330ebeac
3
+ metadata.gz: abc45bf7c07e61197705a9283c38e6d399a81701f433d8a5eded1e6cb6b480e3
4
+ data.tar.gz: ac96de6c442ad806cf3cafa5fc839e5509454a8f315229f4014cddfcd9bbb28e
5
5
  SHA512:
6
- metadata.gz: ed5afdc2c7d07f54b90eb1230d50b1d0bdfb219d3ac6f12d4c2f35c05eb7f0b73c3990c84d65c77567f127c1c082f6e858480165aa0bf1e697bef6aa81517075
7
- data.tar.gz: 01ea007ff63b7e91a94cc7134f57d783680b9a2ba88be5677b93a505eb55d8e39d2cec9f53a3503b5270b2cfcf8a16909569082b19c59c6439d7474f402da7db
6
+ metadata.gz: ef6262279803c776c204d2efd58bb547617519bf8277a78e3a46f3789e39bff21220134556f8c209b3d7fd26eb85627b24062f721de3c87324acb0063ec778e4
7
+ data.tar.gz: 6de7bd208b4ab94ab57b3513159c5ab047f5144fb6152365d52535e3274f8306a416a1124f1c299fe0269542bdb61670958323b8be2285face085f8e3f53ae35
data/.standard.yml CHANGED
@@ -2,11 +2,8 @@ ruby_version: 2.5.0
2
2
  fix: true
3
3
  parallel: true
4
4
  ignore:
5
- - test/**/*
6
- - examples/**/*
7
- - myapp/**/*
8
- - 'lib/faktory.rb':
9
- - Lint/InheritException
10
5
  - 'lib/**/*':
11
- - Lint/RescueException
6
+ - Style/GlobalVars
7
+ - 'test/**/*':
8
+ - Lint/ConstantDefinitionInBlock
12
9
  - Style/GlobalVars
data/Changes.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 1.3.0
4
+
5
+ - Fix `faktory/testing` [#74]
6
+ - Provide more batch helper methods along with a more complex
7
+ workflow in `examples/complex_workflow.rb`.
8
+
3
9
  ## 1.2.0
4
10
 
5
11
  - Dup options before deep merging [#67]
data/Gemfile.lock CHANGED
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faktory_worker_ruby (1.2.0)
4
+ faktory_worker_ruby (1.3.0)
5
5
  connection_pool (~> 2.2, >= 2.2.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activejob (7.0.4.2)
11
- activesupport (= 7.0.4.2)
10
+ activejob (7.0.4.3)
11
+ activesupport (= 7.0.4.3)
12
12
  globalid (>= 0.3.6)
13
- activesupport (7.0.4.2)
13
+ activesupport (7.0.4.3)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
18
  ast (2.4.2)
19
- concurrent-ruby (1.2.0)
20
- connection_pool (2.3.0)
19
+ concurrent-ruby (1.2.2)
20
+ connection_pool (2.4.0)
21
21
  docile (1.4.0)
22
22
  globalid (1.1.0)
23
23
  activesupport (>= 5.0)
@@ -25,42 +25,42 @@ GEM
25
25
  concurrent-ruby (~> 1.0)
26
26
  json (2.6.3)
27
27
  language_server-protocol (3.17.0.3)
28
- minitest (5.17.0)
28
+ minitest (5.18.0)
29
29
  minitest-hooks (1.5.0)
30
30
  minitest (> 5.3)
31
31
  parallel (1.22.1)
32
- parser (3.2.0.0)
32
+ parser (3.2.2.0)
33
33
  ast (~> 2.4.1)
34
34
  rainbow (3.1.1)
35
35
  rake (13.0.6)
36
- regexp_parser (2.6.2)
36
+ regexp_parser (2.7.0)
37
37
  rexml (3.2.5)
38
- rubocop (1.42.0)
38
+ rubocop (1.48.1)
39
39
  json (~> 2.3)
40
40
  parallel (~> 1.10)
41
- parser (>= 3.1.2.1)
41
+ parser (>= 3.2.0.0)
42
42
  rainbow (>= 2.2.2, < 4.0)
43
43
  regexp_parser (>= 1.8, < 3.0)
44
44
  rexml (>= 3.2.5, < 4.0)
45
- rubocop-ast (>= 1.24.1, < 2.0)
45
+ rubocop-ast (>= 1.26.0, < 2.0)
46
46
  ruby-progressbar (~> 1.7)
47
- unicode-display_width (>= 1.4.0, < 3.0)
48
- rubocop-ast (1.24.1)
49
- parser (>= 3.1.1.0)
50
- rubocop-performance (1.15.2)
47
+ unicode-display_width (>= 2.4.0, < 3.0)
48
+ rubocop-ast (1.28.0)
49
+ parser (>= 3.2.1.0)
50
+ rubocop-performance (1.16.0)
51
51
  rubocop (>= 1.7.0, < 2.0)
52
52
  rubocop-ast (>= 0.4.0)
53
- ruby-progressbar (1.11.0)
53
+ ruby-progressbar (1.13.0)
54
54
  simplecov (0.22.0)
55
55
  docile (~> 1.1)
56
56
  simplecov-html (~> 0.11)
57
57
  simplecov_json_formatter (~> 0.1)
58
58
  simplecov-html (0.12.3)
59
59
  simplecov_json_formatter (0.1.4)
60
- standard (1.22.1)
60
+ standard (1.25.3)
61
61
  language_server-protocol (~> 3.17.0.2)
62
- rubocop (= 1.42.0)
63
- rubocop-performance (= 1.15.2)
62
+ rubocop (~> 1.48.1)
63
+ rubocop-performance (~> 1.16.0)
64
64
  tzinfo (2.0.6)
65
65
  concurrent-ruby (~> 1.0)
66
66
  unicode-display_width (2.4.2)
data/bin/faktory-worker CHANGED
@@ -4,7 +4,7 @@
4
4
  # RUBYOPT=-w bundle exec faktory
5
5
  $TESTING = false
6
6
 
7
- require_relative '../lib/faktory/cli'
7
+ require_relative "../lib/faktory/cli"
8
8
 
9
9
  begin
10
10
  cli = Faktory::CLI.instance
@@ -12,7 +12,7 @@ begin
12
12
  cli.run
13
13
  rescue => e
14
14
  raise e if $DEBUG
15
- STDERR.puts e.message
16
- STDERR.puts e.backtrace.join("\n")
15
+ warn e.message
16
+ warn e.backtrace.join("\n")
17
17
  exit 1
18
18
  end
data/lib/faktory/batch.rb CHANGED
@@ -91,6 +91,10 @@ module Faktory
91
91
  @bid = bid
92
92
  end
93
93
 
94
+ def parent=(parent)
95
+ @parent_bid = parent.bid
96
+ end
97
+
94
98
  def success=(val)
95
99
  raise "Batch cannot be modified once created" if bid
96
100
  @success = to_callback(val)
@@ -163,7 +163,9 @@ module Faktory
163
163
  # Hash must contain "jid", "jobtype" and "args" elements at minimum.
164
164
  # Returned value will either be the JID String if successful OR
165
165
  # a symbol corresponding to an error.
166
+ # NB: aliased by faktory/testing
166
167
  def push(job)
168
+ job = job.transform_keys(&:to_s)
167
169
  job["jid"] ||= SecureRandom.hex(12)
168
170
  job["queue"] ||= "default"
169
171
  raise ArgumentError, "Missing `jobtype` attribute: #{job.inspect}" unless job["jobtype"]
@@ -246,6 +248,7 @@ module Faktory
246
248
  @location.scheme =~ /tls/
247
249
  end
248
250
 
251
+ # NB: aliased by faktory/testing
249
252
  def open_socket(timeout = DEFAULT_TIMEOUT)
250
253
  if tls?
251
254
  require "openssl"
data/lib/faktory/job.rb CHANGED
@@ -23,6 +23,7 @@ module Faktory
23
23
  module Job
24
24
  attr_accessor :jid
25
25
  attr_accessor :bid
26
+ attr_accessor :_custom
26
27
 
27
28
  include Faktory::Trackable
28
29
 
@@ -37,12 +38,26 @@ module Faktory
37
38
  Setter.new(options)
38
39
  end
39
40
 
41
+ # this method is typically called within a batch job to reopen
42
+ # the batch in order to add more jobs.
40
43
  def batch
41
44
  if bid
42
45
  @batch ||= Faktory::Batch.new(bid)
43
46
  end
44
47
  end
45
48
 
49
+ # this method is typically called within a child batch callback to reopen
50
+ # the parent batch in order to add more jobs or workflow steps.
51
+ def parent_batch
52
+ if parent_bid
53
+ @parent_batch ||= Faktory::Batch.new(parent_bid)
54
+ end
55
+ end
56
+
57
+ def parent_bid
58
+ _custom["_pbid"]
59
+ end
60
+
46
61
  def logger
47
62
  Faktory.logger
48
63
  end
@@ -5,7 +5,7 @@ module Faktory
5
5
  logger.info("start".freeze)
6
6
  yield
7
7
  logger.info("done: #{elapsed(start)} sec")
8
- rescue Exception
8
+ rescue Exception # rubocop:disable Lint/RescueException
9
9
  logger.info("fail: #{elapsed(start)} sec")
10
10
  raise
11
11
  end
@@ -73,7 +73,7 @@ module Faktory
73
73
  @mgr.processor_stopped(self)
74
74
  rescue Faktory::Shutdown
75
75
  @mgr.processor_stopped(self)
76
- rescue Exception => ex
76
+ rescue Exception => ex # rubocop:disable Lint/RescueException
77
77
  @mgr.processor_died(self, ex)
78
78
  end
79
79
 
@@ -131,6 +131,7 @@ module Faktory
131
131
  klass = constantize(payload["jobtype"])
132
132
  jobinst = klass.new
133
133
  jobinst.jid = payload["jid"]
134
+ jobinst._custom = payload["custom"]
134
135
  yield jobinst
135
136
  end
136
137
  end
@@ -151,7 +152,7 @@ module Faktory
151
152
  # the timeout. Fail it so we can release any locks server-side
152
153
  # and immediately restart it.
153
154
  work.fail(shut)
154
- rescue Exception => ex
155
+ rescue Exception => ex # rubocop:disable Lint/RescueException
155
156
  handle_exception(ex, {context: "Job raised exception", job: work.job})
156
157
  work.fail(ex)
157
158
  raise ex
@@ -76,7 +76,7 @@ module Faktory
76
76
 
77
77
  class Client
78
78
  alias_method :real_push, :push
79
- alias_method :real_open, :open
79
+ alias_method :real_open_socket, :open_socket
80
80
 
81
81
  def push(job)
82
82
  if Faktory::Testing.inline?
@@ -94,9 +94,9 @@ module Faktory
94
94
  end
95
95
  end
96
96
 
97
- def open(*args)
97
+ def open_socket(*args)
98
98
  unless Faktory::Testing.enabled?
99
- real_open(*args)
99
+ real_open_socket(*args)
100
100
  end
101
101
  end
102
102
  end
data/lib/faktory/util.rb CHANGED
@@ -15,7 +15,7 @@ module Faktory
15
15
 
16
16
  def watchdog(last_words)
17
17
  yield
18
- rescue Exception => ex
18
+ rescue Exception => ex # rubocop:disable Lint/RescueException
19
19
  handle_exception(ex, {context: last_words})
20
20
  raise ex
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faktory
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faktory_worker_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-02 00:00:00.000000000 Z
11
+ date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.4.4
157
+ rubygems_version: 3.4.7
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Ruby worker for Faktory