inst-jobs 3.0.2 → 3.0.3

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: 55850c386085b90bbb9df7ff954d40ed7f2035268860ec8b47dfc11f11ec7e51
4
- data.tar.gz: 53065a1f09e8cd30271bc9b57ab58d3bcfff8cf1b9590568379427093de9cbe9
3
+ metadata.gz: fb38d77d225501a3f9ca85561266adf7f2b873d187d0ee9e820e30f773fc5846
4
+ data.tar.gz: 0bdbb7e6609d0c228de6906b68ff41b7a5218b89832dd9f8958ed261d7a39fd2
5
5
  SHA512:
6
- metadata.gz: 8f7d579cddb80890c6158a1384f6828ae91272a864308528ad84e6dc47b3e4769062f91de7ebf9641f4b766c21c571a419385ee57bec9b6e5531f39be30a50a8
7
- data.tar.gz: 887648362dec636b3e1f6938e66dd25b97f42a3e606c5d8466768d5b2ed5137ea50b67c68ce9ec817df86f117ef0660f6ddd3456c86e4871965f89704cc161f3
6
+ metadata.gz: 76c59051987d523e8465c98a0aa03edfa7ee6df1fc090ebeb8238f827d3f5487dccd61f92c20acf87df9b53153de03bb866d577f44eb3d0db18bd3cd9fa44f66
7
+ data.tar.gz: 0262e34514a1919ff9715b1707d7c99dab2ddf4f3ef0c98e06441b61709ddb2bb36c763b73cc5a5512a03e2b2a253b507818da313213a621c40879d086fa9333
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "delayed/plugin"
4
+
5
+ module Delayed
6
+ class RailsReloaderPlugin < Plugin
7
+ callbacks do |lifecycle|
8
+ app = Rails.application
9
+ if app && !app.config.cache_classes
10
+ lifecycle.around(:perform) do |worker, job, &block|
11
+ reload = !app.config.reload_classes_only_on_change || app.reloaders.any?(&:updated?)
12
+
13
+ if reload
14
+ if defined?(ActiveSupport::Reloader)
15
+ Rails.application.reloader.reload!
16
+ else
17
+ ActionDispatch::Reloader.prepare!
18
+ end
19
+ end
20
+
21
+ begin
22
+ block.call(worker, job)
23
+ ensure
24
+ ActionDispatch::Reloader.cleanup! if reload && !defined?(ActiveSupport::Reloader)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delayed
4
- VERSION = "3.0.2"
4
+ VERSION = "3.0.3"
5
5
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "delayed/rails_reloader_plugin"
4
+
3
5
  module Delayed
4
6
  class TimeoutError < RuntimeError; end
5
7
 
@@ -70,27 +72,7 @@ module Delayed
70
72
 
71
73
  @signal_queue = []
72
74
 
73
- app = Rails.application
74
- if app && !app.config.cache_classes
75
- Delayed::Worker.lifecycle.around(:perform) do |worker, job, &block|
76
- reload = app.config.reload_classes_only_on_change != true || app.reloaders.map(&:updated?).any?
77
-
78
- if reload
79
- if defined?(ActiveSupport::Reloader)
80
- Rails.application.reloader.reload!
81
- else
82
- ActionDispatch::Reloader.prepare!
83
- end
84
- end
85
-
86
- begin
87
- block.call(worker, job)
88
- ensure
89
- ActionDispatch::Reloader.cleanup! if reload && !defined?(ActiveSupport::Reloader)
90
- end
91
- end
92
- end
93
-
75
+ plugins << Delayed::RailsReloaderPlugin
94
76
  plugins.each(&:inject!)
95
77
  end
96
78
 
@@ -44,7 +44,7 @@ describe Delayed::Worker do
44
44
  expect(output_count).to eq(1)
45
45
  end
46
46
 
47
- it "reloads" do
47
+ it "reloads Rails classes (never more than once)" do
48
48
  fake_application = double("Rails.application",
49
49
  config: double("Rails.application.config",
50
50
  cache_classes: false,
@@ -59,6 +59,11 @@ describe Delayed::Worker do
59
59
  expect(ActionDispatch::Reloader).to receive(:cleanup!).once
60
60
  end
61
61
  job = double(job_attrs)
62
+
63
+ # Create extra workers to make sure we don't reload multiple times
64
+ described_class.new(worker_config.dup)
65
+ described_class.new(worker_config.dup)
66
+
62
67
  subject.perform(job)
63
68
  end
64
69
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  - Ethan Vizitei
9
9
  - Jacob Burroughs
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-11-08 00:00:00.000000000 Z
13
+ date: 2021-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -424,7 +424,7 @@ dependencies:
424
424
  - - "~>"
425
425
  - !ruby/object:Gem::Version
426
426
  version: 1.4.0
427
- description:
427
+ description:
428
428
  email:
429
429
  - cody@instructure.com
430
430
  - evizitei@instructure.com
@@ -483,6 +483,7 @@ files:
483
483
  - lib/delayed/periodic.rb
484
484
  - lib/delayed/plugin.rb
485
485
  - lib/delayed/pool.rb
486
+ - lib/delayed/rails_reloader_plugin.rb
486
487
  - lib/delayed/server.rb
487
488
  - lib/delayed/server/helpers.rb
488
489
  - lib/delayed/server/public/css/app.css
@@ -531,7 +532,7 @@ files:
531
532
  homepage: https://github.com/instructure/inst-jobs
532
533
  licenses: []
533
534
  metadata: {}
534
- post_install_message:
535
+ post_install_message:
535
536
  rdoc_options: []
536
537
  require_paths:
537
538
  - lib
@@ -546,32 +547,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
546
547
  - !ruby/object:Gem::Version
547
548
  version: '0'
548
549
  requirements: []
549
- rubygems_version: 3.2.24
550
- signing_key:
550
+ rubygems_version: 3.2.15
551
+ signing_key:
551
552
  specification_version: 4
552
553
  summary: Instructure-maintained fork of delayed_job
553
554
  test_files:
554
- - spec/sample_jobs.rb
555
- - spec/spec_helper.rb
556
- - spec/shared_jobs_specs.rb
557
- - spec/shared/performable_method.rb
558
- - spec/shared/testing.rb
559
- - spec/shared/delayed_batch.rb
560
- - spec/shared/worker.rb
561
- - spec/shared/delayed_method.rb
562
- - spec/shared/shared_backend.rb
563
- - spec/migrate/20140924140513_add_story_table.rb
564
- - spec/delayed/server_spec.rb
555
+ - spec/active_record_job_spec.rb
565
556
  - spec/delayed/cli_spec.rb
566
557
  - spec/delayed/daemon_spec.rb
567
- - spec/delayed/worker_spec.rb
568
- - spec/delayed/periodic_spec.rb
569
558
  - spec/delayed/message_sending_spec.rb
559
+ - spec/delayed/periodic_spec.rb
560
+ - spec/delayed/server_spec.rb
570
561
  - spec/delayed/settings_spec.rb
571
562
  - spec/delayed/work_queue/in_process_spec.rb
572
- - spec/delayed/work_queue/parent_process_spec.rb
573
563
  - spec/delayed/work_queue/parent_process/client_spec.rb
574
564
  - spec/delayed/work_queue/parent_process/server_spec.rb
575
- - spec/delayed/worker/health_check_spec.rb
565
+ - spec/delayed/work_queue/parent_process_spec.rb
576
566
  - spec/delayed/worker/consul_health_check_spec.rb
577
- - spec/active_record_job_spec.rb
567
+ - spec/delayed/worker/health_check_spec.rb
568
+ - spec/delayed/worker_spec.rb
569
+ - spec/migrate/20140924140513_add_story_table.rb
570
+ - spec/sample_jobs.rb
571
+ - spec/shared/delayed_batch.rb
572
+ - spec/shared/delayed_method.rb
573
+ - spec/shared/performable_method.rb
574
+ - spec/shared/shared_backend.rb
575
+ - spec/shared/testing.rb
576
+ - spec/shared/worker.rb
577
+ - spec/shared_jobs_specs.rb
578
+ - spec/spec_helper.rb