faktory_worker_ruby 1.2.0 → 2.0.0

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: 57f98beb553cb8d38e36d45b1721c15446201a30db101827d277ef7f3b9fb542
4
- data.tar.gz: a0d82206d826d345bdcde2271ccf300c8af2ccb7ce4c2140900f00b0330ebeac
3
+ metadata.gz: fe9fd54ed547e42b198c7cf2e2f056203857f0f16a65aafe7126006102f86b3b
4
+ data.tar.gz: 9ce604181600566d5991a3e9419f8b48a68d1cf657e8731ef5440eeadff5c4e7
5
5
  SHA512:
6
- metadata.gz: ed5afdc2c7d07f54b90eb1230d50b1d0bdfb219d3ac6f12d4c2f35c05eb7f0b73c3990c84d65c77567f127c1c082f6e858480165aa0bf1e697bef6aa81517075
7
- data.tar.gz: 01ea007ff63b7e91a94cc7134f57d783680b9a2ba88be5677b93a505eb55d8e39d2cec9f53a3503b5270b2cfcf8a16909569082b19c59c6439d7474f402da7db
6
+ metadata.gz: a344b74590b7e16f361fe2be34b69f1d7b07934f59cad91bc06b21dbc619638ac001591e3a5f3e91dabd57526ce1a612f3f28217fe8b61e28b3a29da3104cb0b
7
+ data.tar.gz: a23358b7b261355de860f811b33218704e0d1ee760b794dec7977137e3b2996c8badab2bf0d9d420d468ed539c4b07c6b893a7e99c761659187ae081a3343ef4
@@ -11,7 +11,7 @@ jobs:
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- ruby: ["2.6", "2.7", "3.0", "3.1"]
14
+ ruby: ["2.7", "3.0", "3.1", "3.2", "3.3"]
15
15
  runs-on: ubuntu-latest
16
16
  services:
17
17
  faktory:
data/.standard.yml CHANGED
@@ -1,12 +1,9 @@
1
- ruby_version: 2.5.0
1
+ ruby_version: 2.7.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,17 @@
1
1
  # Changes
2
2
 
3
+ ## HEAD
4
+
5
+ - Allow more connections in pool [#455]
6
+ - Minimum Ruby version is now 2.7.
7
+ - Minimum Rails version is now 6.0.
8
+
9
+ ## 1.3.0
10
+
11
+ - Fix `faktory/testing` [#74]
12
+ - Provide more batch helper methods along with a more complex
13
+ workflow in `examples/complex_workflow.rb`.
14
+
3
15
  ## 1.2.0
4
16
 
5
17
  - Dup options before deep merging [#67]
data/Gemfile.lock CHANGED
@@ -1,69 +1,92 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faktory_worker_ruby (1.2.0)
4
+ faktory_worker_ruby (2.0.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.1.3)
11
+ activesupport (= 7.1.3)
12
12
  globalid (>= 0.3.6)
13
- activesupport (7.0.4.2)
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.2.0)
20
- connection_pool (2.3.0)
24
+ base64 (0.2.0)
25
+ bigdecimal (3.1.6)
26
+ concurrent-ruby (1.2.3)
27
+ connection_pool (2.4.1)
21
28
  docile (1.4.0)
22
- globalid (1.1.0)
23
- activesupport (>= 5.0)
24
- i18n (1.12.0)
29
+ drb (2.2.0)
30
+ ruby2_keywords
31
+ globalid (1.2.1)
32
+ activesupport (>= 6.1)
33
+ i18n (1.14.1)
25
34
  concurrent-ruby (~> 1.0)
26
- json (2.6.3)
35
+ json (2.7.1)
27
36
  language_server-protocol (3.17.0.3)
28
- minitest (5.17.0)
29
- minitest-hooks (1.5.0)
37
+ lint_roller (1.1.0)
38
+ minitest (5.21.2)
39
+ minitest-hooks (1.5.1)
30
40
  minitest (> 5.3)
31
- parallel (1.22.1)
32
- parser (3.2.0.0)
41
+ mutex_m (0.2.0)
42
+ parallel (1.24.0)
43
+ parser (3.3.0.4)
33
44
  ast (~> 2.4.1)
45
+ racc
46
+ racc (1.7.3)
34
47
  rainbow (3.1.1)
35
- rake (13.0.6)
36
- regexp_parser (2.6.2)
37
- rexml (3.2.5)
38
- rubocop (1.42.0)
48
+ rake (13.1.0)
49
+ regexp_parser (2.9.0)
50
+ rexml (3.2.6)
51
+ rubocop (1.59.0)
39
52
  json (~> 2.3)
53
+ language_server-protocol (>= 3.17.0)
40
54
  parallel (~> 1.10)
41
- parser (>= 3.1.2.1)
55
+ parser (>= 3.2.2.4)
42
56
  rainbow (>= 2.2.2, < 4.0)
43
57
  regexp_parser (>= 1.8, < 3.0)
44
58
  rexml (>= 3.2.5, < 4.0)
45
- rubocop-ast (>= 1.24.1, < 2.0)
59
+ rubocop-ast (>= 1.30.0, < 2.0)
46
60
  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)
51
- rubocop (>= 1.7.0, < 2.0)
52
- rubocop-ast (>= 0.4.0)
53
- ruby-progressbar (1.11.0)
61
+ unicode-display_width (>= 2.4.0, < 3.0)
62
+ rubocop-ast (1.30.0)
63
+ parser (>= 3.2.1.0)
64
+ rubocop-performance (1.20.2)
65
+ rubocop (>= 1.48.1, < 2.0)
66
+ rubocop-ast (>= 1.30.0, < 2.0)
67
+ ruby-progressbar (1.13.0)
68
+ ruby2_keywords (0.0.5)
54
69
  simplecov (0.22.0)
55
70
  docile (~> 1.1)
56
71
  simplecov-html (~> 0.11)
57
72
  simplecov_json_formatter (~> 0.1)
58
73
  simplecov-html (0.12.3)
59
74
  simplecov_json_formatter (0.1.4)
60
- standard (1.22.1)
75
+ standard (1.33.0)
61
76
  language_server-protocol (~> 3.17.0.2)
62
- rubocop (= 1.42.0)
63
- rubocop-performance (= 1.15.2)
77
+ lint_roller (~> 1.0)
78
+ rubocop (~> 1.59.0)
79
+ standard-custom (~> 1.0.0)
80
+ standard-performance (~> 1.3)
81
+ standard-custom (1.0.2)
82
+ lint_roller (~> 1.0)
83
+ rubocop (~> 1.50)
84
+ standard-performance (1.3.1)
85
+ lint_roller (~> 1.1)
86
+ rubocop-performance (~> 1.20.2)
64
87
  tzinfo (2.0.6)
65
88
  concurrent-ruby (~> 1.0)
66
- unicode-display_width (2.4.2)
89
+ unicode-display_width (2.5.0)
67
90
 
68
91
  PLATFORMS
69
92
  ruby
@@ -76,3 +99,6 @@ DEPENDENCIES
76
99
  rake
77
100
  simplecov
78
101
  standard
102
+
103
+ BUNDLED WITH
104
+ 2.4.22
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
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.executables = ["faktory-worker"]
13
13
  gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
14
14
  gem.version = Faktory::VERSION
15
- gem.required_ruby_version = ">= 2.5.0"
15
+ gem.required_ruby_version = ">= 2.7.0"
16
16
 
17
17
  gem.metadata = {
18
18
  "homepage_uri" => "https://contribsys.com/faktory",
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
  }
24
24
 
25
25
  gem.add_dependency "connection_pool", "~> 2.2", ">= 2.2.2"
26
- gem.add_development_dependency "activejob", ">= 5.2.0"
26
+ gem.add_development_dependency "activejob", ">= 6.0.0"
27
27
  gem.add_development_dependency "minitest", "~> 5"
28
28
  gem.add_development_dependency "minitest-hooks"
29
29
  gem.add_development_dependency "rake"
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"
@@ -344,9 +347,9 @@ module Faktory
344
347
  raise Errno::ECONNRESET, "No response" unless line
345
348
  chr = line[0]
346
349
  if chr == "+"
347
- line[1..-1].strip
350
+ line[1..].strip
348
351
  elsif chr == "$"
349
- count = line[1..-1].strip.to_i
352
+ count = line[1..].strip.to_i
350
353
  return nil if count == -1
351
354
  data = read(count) if count > 0
352
355
  _ = gets # read extra linefeeds
@@ -359,7 +362,7 @@ module Faktory
359
362
  #
360
363
  # -NOTUNIQUE Job not unique
361
364
  # We return ["NOTUNIQUE", "Job not unique"]
362
- err = line[1..-1].split(" ", 2)
365
+ err = line[1..].split(" ", 2)
363
366
  raise CommandError, err[1] if err[0] == "ERR"
364
367
  err
365
368
  else
@@ -6,7 +6,7 @@ module Faktory
6
6
  class Connection
7
7
  class << self
8
8
  def create(options = {})
9
- size = Faktory.worker? ? (Faktory.options[:concurrency] + 2) : 5
9
+ size = Faktory.worker? ? (Faktory.options[:concurrency] + 5) : 20
10
10
  ConnectionPool.new(timeout: options[:pool_timeout] || 1, size: size) do
11
11
  Faktory::Client.new(**options)
12
12
  end
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
@@ -158,7 +173,7 @@ module Faktory
158
173
  m = "#{name}="
159
174
  undef_method(m) if method_defined?(m) || private_method_defined?(m)
160
175
  end
161
- define_singleton_method("#{name}=") do |val|
176
+ define_singleton_method(:"#{name}=") do |val|
162
177
  singleton_class.class_eval do
163
178
  undef_method(name) if method_defined?(name) || private_method_defined?(name)
164
179
  define_method(name) { val }
@@ -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
@@ -62,7 +62,7 @@ module Faktory
62
62
  end
63
63
 
64
64
  def self.logger=(log)
65
- @logger = (log || Logger.new(File::NULL))
65
+ @logger = log || Logger.new(File::NULL)
66
66
  end
67
67
 
68
68
  def logger
@@ -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
data/lib/faktory/rails.rb CHANGED
@@ -22,7 +22,7 @@ module Faktory
22
22
  # None of this matters on the client-side, only within the Faktory executor itself.
23
23
  #
24
24
  Faktory.configure_worker do |_|
25
- if ::Rails::VERSION::MAJOR < 5
25
+ if ::Rails::VERSION::MAJOR < 6
26
26
  raise "Your current version of Rails, #{::Rails::VERSION::STRING}, is not supported"
27
27
  end
28
28
 
@@ -58,9 +58,9 @@ module Faktory
58
58
  end
59
59
  end
60
60
 
61
- if defined?(::Rails) && ::Rails::VERSION::MAJOR < 5
61
+ if defined?(::Rails) && ::Rails::VERSION::MAJOR < 6
62
62
  warn("**************************************************")
63
- warn("🚫 ERROR: Faktory Worker does not support Rails versions under 5.x - please ensure your workers are updated")
63
+ warn("🚫 ERROR: Faktory Worker does not support Rails version < 6.x")
64
64
  warn("**************************************************")
65
65
  warn("")
66
66
  end
@@ -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 = "2.0.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: 2.0.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: 2024-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 5.2.0
39
+ version: 6.0.0
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 5.2.0
46
+ version: 6.0.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -147,14 +147,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: 2.5.0
150
+ version: 2.7.0
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.4.4
157
+ rubygems_version: 3.4.20
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Ruby worker for Faktory