worker_killer 1.0.1.83603 → 1.0.2.187732

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: af1736e1bb8f2bfc3c3aa9e93d2fa1aa429173dc2389e7969c24210479e90441
4
- data.tar.gz: f472d15158b29d0a920e49f873b46edcc19f554c0d3a75cfe33cf43b195ed0d6
3
+ metadata.gz: a0a5748a9d257aeacb4e2c486fc9272e7596a0eb1209c6e36c0bc28266677006
4
+ data.tar.gz: d64b7e01f1b29bfa09abd1766671c2bf6194a01de0534a5ee1dafb9c5075ca40
5
5
  SHA512:
6
- metadata.gz: 2796b66e4f0069df66073c2acdc2cefa7c2213efdf36ddaf7a76e63cdc9bf53ffe4b369406bb8e6dd890d6f242b47f44fcd4cfde83e73b499f8d1e002097a8bd
7
- data.tar.gz: a3d13754ae85c50564e8b825d61ec8d0397b1e664647e3b18a4423426f081b6a6bada3e26941773415856afa1e5abab8fdf04a88045beb2f2b704054f0d1517e
6
+ metadata.gz: bc1f156405493859b4cf0ddf1cc372eae5dee1ca861e761a4bfcba59bd41702e58edae47c1e813be460183258550b9c5b8cc00eb918c33157af2a57d91ad489d
7
+ data.tar.gz: aa97b6c4cae358769e76f70b553b842bcdf79457f63fefe97c5ec3dea27fa4f5797ba519991efd29a139a35b63baacd3fd861a7ca7fc37affa0a24ff038de97c
@@ -14,15 +14,22 @@ module WorkerKiller
14
14
  end
15
15
 
16
16
  @limiter = klass.new(**opts)
17
+ @time_to_burn = false
17
18
  end
18
19
 
19
- def new(*_args)
20
- configure_lifecycle(Delayed::Worker.lifecycle)
20
+ def new(lifecycle = Delayed::Worker.lifecycle, *_args)
21
+ configure_lifecycle(lifecycle)
21
22
  end
22
23
 
23
24
  def configure_lifecycle(lifecycle)
25
+ # Count condition after every job
24
26
  lifecycle.after(:perform) do |worker, *_args|
25
- reaction.call(limiter, killer, worker) if limiter.check
27
+ @time_to_burn = limiter.check
28
+ end
29
+
30
+ # Stop execution only after whole loop completed
31
+ lifecycle.after(:loop) do |worker, *_args|
32
+ reaction.call(limiter, killer, worker) if @time_to_burn
26
33
  end
27
34
  end
28
35
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module WorkerKiller
4
4
 
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
 
7
7
  end
8
8
 
@@ -0,0 +1,17 @@
1
+ RSpec.describe WorkerKiller::DelayedJobPlugin::JobsLimiter do
2
+
3
+ let(:killer) {double}
4
+ subject(:plugin){ described_class.new(killer: killer) }
5
+
6
+ context 'DelayedJob initialization' do
7
+ let(:lifecycle) { double }
8
+ subject(:instance) { plugin.new(lifecycle) }
9
+
10
+ it do
11
+ expect(lifecycle).to receive(:after).with(:perform).and_yield
12
+ expect(lifecycle).to receive(:after).with(:loop).and_yield
13
+ instance
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,17 @@
1
+ RSpec.describe WorkerKiller::DelayedJobPlugin::OOMLimiter do
2
+
3
+ let(:killer) {double}
4
+ subject(:plugin){ described_class.new(killer: killer) }
5
+
6
+ context 'DelayedJob initialization' do
7
+ let(:lifecycle) { double }
8
+ subject(:instance) { plugin.new(lifecycle) }
9
+
10
+ it do
11
+ expect(lifecycle).to receive(:after).with(:perform).and_yield
12
+ expect(lifecycle).to receive(:after).with(:loop).and_yield
13
+ instance
14
+ end
15
+ end
16
+ end
17
+
@@ -6,8 +6,8 @@ RSpec.describe WorkerKiller::Killer::DelayedJob do
6
6
  end
7
7
  end
8
8
 
9
- let(:killer){ described_class.new() }
10
9
  let(:dj){ double }
10
+ subject(:killer){ described_class.new() }
11
11
 
12
12
  describe '#kill' do
13
13
  context 'with use_quit TRUE' do
@@ -30,5 +30,6 @@ RSpec.describe WorkerKiller::Killer::DelayedJob do
30
30
  end
31
31
  end
32
32
  end
33
+
33
34
  end
34
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_killer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1.83603
4
+ version: 1.0.2.187732
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-29 00:00:00.000000000 Z
11
+ date: 2023-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: get_process_mem
@@ -136,6 +136,8 @@ files:
136
136
  - lib/worker_killer/middleware.rb
137
137
  - lib/worker_killer/version.rb
138
138
  - spec/count_limiter_spec.rb
139
+ - spec/delayed_job_plugin/jobs_limiter_spec.rb
140
+ - spec/delayed_job_plugin/oom_limiter_spec.rb
139
141
  - spec/killer/delayed_job_spec.rb
140
142
  - spec/killer/passenger_spec.rb
141
143
  - spec/killer/signal_spec.rb
@@ -178,4 +180,6 @@ test_files:
178
180
  - spec/support/logger.rb
179
181
  - spec/middleware_spec.rb
180
182
  - spec/spec_helper.rb
183
+ - spec/delayed_job_plugin/oom_limiter_spec.rb
184
+ - spec/delayed_job_plugin/jobs_limiter_spec.rb
181
185
  - spec/memory_limiter_spec.rb