backburner 1.9.0 → 1.9.2

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: ad41e83594bda50d1b504a4e0e5777c477e5586dc88faddbbad476a81afb34d4
4
- data.tar.gz: f53ac6873638f40f627bbcd1326f50fbd642e5454bce2c083b809cdc6904863b
3
+ metadata.gz: 9e06b3212ccce4ab8c5e0ca50f73261c231b141ecb7b64d6837b9ae226d02135
4
+ data.tar.gz: bd6edd04a207e72a8f99d9d73666e6f3d1bf98141021db69b6ea709670b551e7
5
5
  SHA512:
6
- metadata.gz: '0384db95f53944823490c2105948153c8aac2d0fb5e8268c8c6f82895ae722bf293bb93f7a0536967a9ad91a138d37f02d92f4f2b0e6860a749cb830065dd668'
7
- data.tar.gz: 1e6cbde19cd41a7540346d5d66af0537af1fc53baec32466790217b0643b610cbd7d17f8ea74b1ed6aedd55a26c152d798df86f4ef6b21ac11b5bc848db9d175
6
+ metadata.gz: e01c8cb470a1a0d8b8f2158ba0a7c52307af43ab7137018133a12a1a83f90334f2a9b84c9115335ceaf9ec7d121042ed2d158e97b472382a61508ede94d2e48d
7
+ data.tar.gz: c58269a6b2024ea948f5ae254f5828723d2562cd78039bf363885ae15ccbd1c2697e9a0588837d186a91078e1d011a91bc29b26405f630b273352e800c144214
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Version 1.9.2 (Dec 2 2026)
4
+
5
+ * Fix Active Job jobs ignoring their class's `queue_respond_timeout` on Rails 7.2 and newer when, without Bundler, Active Job is required before backburner (`require 'rails/all'` or `require 'active_job'`, then `require 'backburner'`): Active Job's own adapter loaded instead of this gem's, so every job got `config.respond_timeout` as its TTR. `require 'backburner'` now loads this gem's adapter, unless Active Job has already loaded its own. Nothing changes on Rails before 7.2. An app without Bundler that never requires backburner itself still gets Active Job's adapter: add `require 'backburner'` (#207)
6
+ * Fix the Forking worker watching the wrong tubes when its connection is reconnected (`Connection#reconnect!`): `Forking#on_reconnect` ran `prepare` again, re-expanding `tube_names` (with an uppercase `tube_namespace`, `MyApp.default` became `MyApp.my-app.default`). It now re-watches its already-expanded tubes, as `Simple#on_reconnect` does, and no longer runs `prepare` on reconnect (#205)
7
+
8
+ ## Version 1.9.1 (Nov 5 2026)
9
+
10
+ * Faster hook lookup: finding a job class's hooks (`before_enqueue`, `before_perform` and the others) no longer lists every method each class has, so Backburner's own work per job is lighter: enqueueing takes about 30-40% less time and working a job about 15-30% less (more with Active Support loaded), measured with no-op jobs against a local beanstalkd. The same hooks run, in the same order
11
+
3
12
  ## Version 1.9.0 (Nov 1 2026)
4
13
 
5
14
  * The gem now ships only `lib/`, `bin/`, `README.md`, `HOOKS.md`, `CHANGELOG.md` and `LICENSE` (no tests, examples or CI files), and its rubygems.org page links the source, the changelog and the issue tracker. **Behaviour change for the gem's owners:** pushing a release to rubygems.org now requires MFA (`rubygems_mfa_required`); the release workflow's trusted publishing is unaffected. **What to do:** owners who push by hand need MFA enabled on their rubygems.org account
@@ -46,8 +46,53 @@ module Backburner
46
46
  # # => ['before_enqueue_foo', 'before_enqueue_bar']
47
47
  #
48
48
  def find_hook_events(hookable, event)
49
- (hookable.methods - Object.methods).grep(/^#{event}/).sort
49
+ pattern = HOOK_PATTERNS[event] || /^#{event}/
50
+ (class_hook_events(hookable, pattern) || (hookable.methods - Object.methods).grep(pattern)).sort
50
51
  end
52
+
53
+ # The names (hookable.methods - Object.methods).grep(pattern) gives for a class, without listing every method
54
+ # each class has: a class's methods are looked up in its own modules (its singleton class, its superclasses'
55
+ # and the modules they extend) and then in Object's, so a name none of its own modules define is looked up
56
+ # as on Object, and Object.methods has it too. nil for anything else (an instance, a module, a class that
57
+ # doesn't end in Object's modules, or a class or Object that doesn't list its methods with Kernel's own public
58
+ # #methods).
59
+ def class_hook_events(hookable, pattern)
60
+ return unless Class === hookable
61
+ singleton = SINGLETON_CLASS.bind_call(hookable)
62
+ object = SINGLETON_CLASS.bind_call(Object)
63
+ return unless kernel_listing?(singleton) && kernel_listing?(object)
64
+ ancestors = ANCESTORS.bind_call(singleton)
65
+ objects = ANCESTORS.bind_call(object)
66
+ own = ancestors.size - objects.size
67
+ return unless own > 0 && ancestors.last(objects.size) == objects
68
+ # a name the class lists is public or protected where it is looked up, so one of them lists it
69
+ names = ancestors.first(own).flat_map { |mod| INSTANCE_METHODS.bind_call(mod, false).grep(pattern) }
70
+ names.uniq.select { |name| listed?(singleton, name) && !listed?(object, name) }
71
+ end
72
+
73
+ # Whether an object whose singleton class is `singleton` lists its methods with Kernel's own public #methods
74
+ def kernel_listing?(singleton)
75
+ return false unless PUBLIC_METHOD_DEFINED.bind_call(singleton, :methods)
76
+ listing = INSTANCE_METHOD.bind_call(singleton, :methods)
77
+ listing.owner.equal?(Kernel) && listing.original_name == :methods && listing.source_location.nil?
78
+ end
79
+
80
+ # Whether an object whose singleton class is `singleton` lists the method in #methods (a public or protected one)
81
+ def listed?(singleton, name)
82
+ PUBLIC_METHOD_DEFINED.bind_call(singleton, name) || PROTECTED_METHOD_DEFINED.bind_call(singleton, name)
83
+ end
84
+
85
+ # The patterns of the events Backburner triggers, compiled once
86
+ HOOK_PATTERNS = %i[before_enqueue after_enqueue before_perform around_perform after_perform on_failure on_bury
87
+ on_retry on_reconnect].to_h { |event| [event, /^#{event}/] }.freeze
88
+
89
+ # Kernel's and Module's own reflection, whatever a class or module defines for itself
90
+ SINGLETON_CLASS = Kernel.instance_method(:singleton_class)
91
+ ANCESTORS = Module.instance_method(:ancestors)
92
+ INSTANCE_METHODS = Module.instance_method(:instance_methods)
93
+ INSTANCE_METHOD = Module.instance_method(:instance_method)
94
+ PUBLIC_METHOD_DEFINED = Module.instance_method(:public_method_defined?)
95
+ PROTECTED_METHOD_DEFINED = Module.instance_method(:protected_method_defined?)
51
96
  end
52
97
  end # Hooks
53
98
  end # Backburner
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "1.9.0"
2
+ VERSION = "1.9.2"
3
3
  end
@@ -37,9 +37,9 @@ module Backburner
37
37
  Process.wait(pid)
38
38
  end
39
39
 
40
+ # A reconnected connection only watches the default tube: watch ours again
40
41
  def on_reconnect(conn)
41
- @connection = conn
42
- prepare
42
+ conn.tubes.watch!(*self.tube_names)
43
43
  end
44
44
 
45
45
  # Exit with Kernel.exit! to avoid at_exit callbacks that should belongs to
data/lib/backburner.rb CHANGED
@@ -18,9 +18,11 @@ require 'backburner/workers/threading'
18
18
  require 'backburner/queue'
19
19
  # On Rails 7.2+ (which added AbstractAdapter) use this gem's Active Job adapter; older Rails autoload theirs.
20
20
  # Not when Rails' autoload has already loaded the adapter or is loading it (an adapter file requires backburner).
21
+ # By its own path: Rails' adapter file has the same name, and comes first on the load path when Active Job was
22
+ # activated before this gem (without Bundler).
21
23
  if defined?(ActiveJob::QueueAdapters::AbstractAdapter) && (ActiveJob::QueueAdapters.autoload?(:BackburnerAdapter) ||
22
24
  !ActiveJob::QueueAdapters.constants(false).include?(:BackburnerAdapter))
23
- require 'active_job/queue_adapters/backburner_adapter'
25
+ require File.expand_path('../active_job/queue_adapters/backburner_adapter', __FILE__)
24
26
  end
25
27
 
26
28
  module Backburner
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backburner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-01 00:00:00.000000000 Z
11
+ date: 2026-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beaneater