delayed 0.2.0 → 0.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: 85f15f2dc879ebed5a25beae7fc11187698a6254501bf9502888c4945e9979dd
4
- data.tar.gz: e5529cd4ad7d407618ea3f2154978285399422d9e5e2334403628ff39bb07829
3
+ metadata.gz: 6690016ceeb6764ea0d848c7b8f065f1c5c7587b1a6f519f81f90131c2a77c30
4
+ data.tar.gz: 83dc7b900584296c9c383ca5171f087da2c71cbbc44e5dca1898e03e2716ab6f
5
5
  SHA512:
6
- metadata.gz: e0851d47484cf6f8a782d47c544cb34f8591b155466dfcf7096610fb360494a0c037beda3bde9621036d272acc63283d1b755a2472bab563540ba71dda861be6
7
- data.tar.gz: 704ea837b5c769f689aef8680d54ace64dcfbbab40802406bceff3a700fde6be1c60270e96ad10e5f4d4575f9da8de245942ab8e7af64438eed9ff6f94aead16
6
+ metadata.gz: d39684e6f3d1fafff2ee632ec243ca5e387f30fa970125f16c456410c5a69ea25fcf906b61d7015e53e40743f9d76133f3054c3fcb781c381c46ea9454d44d42
7
+ data.tar.gz: '08f057ac20053b5e7a04c98a5b14214ebf43ff0056798a456229482303057c7a68eb08d84d4724d0c3058348ec04d9a3f08db9f1bc5f2dd4528de9161e405ddb'
data/README.md CHANGED
@@ -13,9 +13,11 @@ It supports **postgres**, **mysql**, and **sqlite**, and is designed to be:
13
13
  - **Resilient**, with built-in retry mechanisms, exponential back-off, and failed job preservation
14
14
  - **Maintainable**, with robust instrumentation, continuous monitoring, and priority-based alerting
15
15
 
16
- For an overview of how Betterment uses `delayed` to build resilience into distributed systems, check
17
- out the talk ✨[Can I break this?](https://www.youtube.com/watch?v=TuhS13rBoVY)✨ given at RailsConf
18
- 2021!
16
+ For an overview of how Betterment uses `delayed` to build resilience into distributed systems, read
17
+ the
18
+ [announcement blog post](https://www.betterment.com/resources/delayed-resilient-background-jobs-on-rails/),
19
+ and/or check out the talk ✨[Can I break this?](https://www.youtube.com/watch?v=TuhS13rBoVY)✨
20
+ given at RailsConf 2021!
19
21
 
20
22
 
21
23
  ### Why `Delayed`?
@@ -163,13 +163,19 @@ module Delayed
163
163
  def self.db_time_now
164
164
  if Time.zone
165
165
  Time.zone.now
166
- elsif ::ActiveRecord::Base.default_timezone == :utc
166
+ elsif default_timezone == :utc
167
167
  Time.now.utc
168
168
  else
169
169
  Time.current
170
170
  end
171
171
  end
172
172
 
173
+ if ActiveRecord::VERSION::MAJOR >= 7
174
+ def self.default_timezone
175
+ ActiveRecord.default_timezone
176
+ end
177
+ end
178
+
173
179
  def self.worker_tags(worker)
174
180
  {
175
181
  min_priority: worker.min_priority,
@@ -150,7 +150,7 @@ module Delayed
150
150
  private
151
151
 
152
152
  def respond_to_missing?(method_name, include_private = false)
153
- method_name.to_s.end_with?('?') && self.class.names.key?(method_name.to_s[0..-2].to_sym) || super
153
+ (method_name.to_s.end_with?('?') && self.class.names.key?(method_name.to_s[0..-2].to_sym)) || super
154
154
  end
155
155
 
156
156
  def method_missing(method_name, *args)
@@ -21,7 +21,7 @@ module Delayed
21
21
  def on_exit!; end
22
22
 
23
23
  def interruptable_sleep(seconds)
24
- IO.select([pipe[0]], nil, nil, seconds)
24
+ pipe[0].wait_readable(seconds)
25
25
  end
26
26
 
27
27
  def stop
@@ -739,10 +739,16 @@ describe Delayed::Job do
739
739
  end
740
740
  end
741
741
 
742
+ if ActiveRecord::VERSION::MAJOR >= 7
743
+ delegate :default_timezone=, to: ActiveRecord
744
+ else
745
+ delegate :default_timezone=, to: ActiveRecord::Base
746
+ end
747
+
742
748
  context "db_time_now" do
743
749
  after do
744
750
  Time.zone = nil
745
- ActiveRecord::Base.default_timezone = :local
751
+ self.default_timezone = :local
746
752
  end
747
753
 
748
754
  it "returns time in current time zone if set" do
@@ -752,13 +758,13 @@ describe Delayed::Job do
752
758
 
753
759
  it "returns UTC time if that is the AR default" do
754
760
  Time.zone = nil
755
- ActiveRecord::Base.default_timezone = :utc
761
+ self.default_timezone = :utc
756
762
  expect(described_class.db_time_now.zone).to eq "UTC"
757
763
  end
758
764
 
759
765
  it "returns local time if that is the AR default" do
760
766
  Time.zone = "Arizona"
761
- ActiveRecord::Base.default_timezone = :local
767
+ self.default_timezone = :local
762
768
  expect(described_class.db_time_now.zone).to eq("MST")
763
769
  end
764
770
  end
data/spec/helper.rb CHANGED
@@ -139,8 +139,15 @@ RSpec.configure do |config|
139
139
  end
140
140
  end
141
141
 
142
- # Add this directory so the ActiveSupport autoloading works
143
- ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__)
142
+ if ActiveRecord::VERSION::MAJOR >= 7
143
+ require "zeitwerk"
144
+ loader = Zeitwerk::Loader.new
145
+ loader.push_dir File.dirname(__FILE__)
146
+ loader.setup
147
+ else
148
+ # Add this directory so the ActiveSupport autoloading works
149
+ ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__)
150
+ end
144
151
 
145
152
  RSpec::Matchers.define :emit_notification do |expected_event_name|
146
153
  attr_reader :actual, :expected
@@ -25,7 +25,7 @@ describe 'YAML' do
25
25
  it 'autoloads the class of an anonymous struct' do
26
26
  expect {
27
27
  yaml = "--- !ruby/struct\nn: 1\n"
28
- object = YAML.load(yaml)
28
+ object = load_with_delayed_visitor(yaml)
29
29
  expect(object).to be_kind_of(Struct)
30
30
  expect(object.n).to eq(1)
31
31
  }.not_to raise_error
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Griffith
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2021-09-02 00:00:00.000000000 Z
22
+ date: 2021-10-26 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: activerecord
@@ -203,6 +203,20 @@ dependencies:
203
203
  - - ">="
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: zeitwerk
208
+ requirement: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ type: :development
214
+ prerelease: false
215
+ version_requirements: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - ">="
218
+ - !ruby/object:Gem::Version
219
+ version: '0'
206
220
  description: |
207
221
  Delayed is a multi-threaded, SQL-driven ActiveJob backend used at Betterment to process millions
208
222
  of background jobs per day. It supports postgres, mysql, and sqlite, and is designed to be
@@ -291,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
305
  - !ruby/object:Gem::Version
292
306
  version: '0'
293
307
  requirements: []
294
- rubygems_version: 3.2.26
308
+ rubygems_version: 3.1.6
295
309
  signing_key:
296
310
  specification_version: 4
297
311
  summary: a multi-threaded, SQL-driven ActiveJob backend used at Betterment to process