copy_tuner_client 0.13.6 → 0.14.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: 18a9b47fc9ce6eb6887518560e3f70b45068b49a3f96a69ddba25a0881a5f0eb
4
- data.tar.gz: bab8e9d03f8a9234c08ccb2a14f2110c1bf82b57054aec363fb9d5cb60497bd1
3
+ metadata.gz: 0c3aa96213cfb378917e854a87a2d123811e5b680ac1d0cad51d0a7c5cd63ac0
4
+ data.tar.gz: 690b11ad48005c79a59c50132b0f3f603160353cd45a29dc72f63f02f480ee08
5
5
  SHA512:
6
- metadata.gz: 736eccf7b435cdd6a800adea2a8a9134efcda643dd470648b2e6f391685eb09fb80a81fc5dba261140af4a2ebbabe384b51d553ff09f663b40986f702f9f6e56
7
- data.tar.gz: 82a552afe1876391d165600f02336e544d5ba78dc8b596a015917bd04f116dd785daf87ba58f3e31b117ad76b735dab4f8a594de5c1055118a8e5a0a192f2c11
6
+ metadata.gz: ba67841e0fe4bd9472bb6ff773cd1c91b3a50dbe899d6bd44f1aebba03601dbc42be664dcbb08de920c11a9c6b33acedbf00e342f0db22e3c3894fad0270d066
7
+ data.tar.gz: a6f481140fcce7273249f76b00a28a5e935419c965bf5efa57f100de13d4b9de11ac0310c706e65557763cb3372dbb951d040c23f5acc2ffb5026f1aa77be105
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.14.0
2
+
3
+ - Add Support for good_job
4
+ - Drop Support for Resque
5
+
1
6
  ## 0.13.5
2
7
 
3
8
  - Rename assets
@@ -18,7 +18,6 @@ module CopyTunerClient
18
18
  register_spawn_hooks
19
19
  else
20
20
  register_exit_hooks
21
- register_job_hooks
22
21
  start_polling
23
22
  end
24
23
  end
@@ -30,7 +29,7 @@ module CopyTunerClient
30
29
  end
31
30
 
32
31
  def spawner?
33
- passenger_spawner? || unicorn_spawner? || delayed_job_spawner? || puma_spawner?
32
+ passenger_spawner? || unicorn_spawner? || delayed_job_spawner? || puma_spawner? || good_job_spawner?
34
33
  end
35
34
 
36
35
  def passenger_spawner?
@@ -53,6 +52,10 @@ module CopyTunerClient
53
52
  defined?(Delayed::Worker) && $0.include?('delayed_job')
54
53
  end
55
54
 
55
+ def good_job_spawner?
56
+ $0.include?('good_job') && defined?(GoodJob) && ARGV.include?('--daemonize')
57
+ end
58
+
56
59
  def register_spawn_hooks
57
60
  if passenger_spawner?
58
61
  register_passenger_hook
@@ -62,6 +65,8 @@ module CopyTunerClient
62
65
  register_puma_hook
63
66
  elsif delayed_job_spawner?
64
67
  register_delayed_hook
68
+ elsif good_job_spawner?
69
+ register_good_job_hook
65
70
  end
66
71
  end
67
72
 
@@ -96,6 +101,18 @@ module CopyTunerClient
96
101
  end
97
102
  end
98
103
 
104
+ def register_good_job_hook
105
+ @logger.info("Registered good_job start hook")
106
+ poller = @poller
107
+ hook_module = Module.new do
108
+ define_method :daemon do
109
+ super
110
+ poller.start
111
+ end
112
+ end
113
+ ::Process.singleton_class.prepend hook_module
114
+ end
115
+
99
116
  def register_puma_hook
100
117
  # If Puma is clustered mode without preload_app, this method is called on worker process.
101
118
  # Just start poller and return.
@@ -112,7 +129,7 @@ module CopyTunerClient
112
129
  hook_module = Module.new do
113
130
  define_method :start_server do
114
131
  poller.start
115
- super()
132
+ super
116
133
  end
117
134
  end
118
135
  Puma::Runner.prepend hook_module
@@ -123,20 +140,5 @@ module CopyTunerClient
123
140
  @cache.flush
124
141
  end
125
142
  end
126
-
127
- def register_job_hooks
128
- if defined?(Resque::Job)
129
- @logger.info("Registered Resque after_perform hook")
130
- cache = @cache
131
- Resque::Job.class_eval do
132
- alias_method :perform_without_copy_tuner, :perform
133
- define_method :perform do
134
- job_was_performed = perform_without_copy_tuner
135
- cache.flush
136
- job_was_performed
137
- end
138
- end
139
- end
140
- end
141
143
  end
142
144
  end
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '0.13.6'.freeze
3
+ VERSION = '0.14.0'.freeze
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze
@@ -91,28 +91,4 @@ describe CopyTunerClient::ProcessGuard do
91
91
 
92
92
  expect(cache).to be_written
93
93
  end
94
-
95
- it "flushes after running a resque job" do
96
- logger = FakeLogger.new
97
- cache = WritingCache.new
98
- define_constant('Resque', Module.new)
99
- job_class = define_constant('Resque::Job', FakeResqueJob)
100
- job = job_class.new
101
- process_guard = build_process_guard(:cache => cache, :logger => logger)
102
-
103
- process_guard.start
104
- job.fork_and_perform
105
-
106
- expect(cache).to be_written
107
- expect(logger).to have_entry(:info, "Registered Resque after_perform hook")
108
- end
109
-
110
- it "doesn't fail if only Resque is defined and not Resque::Job" do
111
- logger = FakeLogger.new
112
- cache = WritingCache.new
113
- define_constant('Resque', Module.new)
114
- process_guard = build_process_guard(:cache => cache, :logger => logger)
115
-
116
- process_guard.start
117
- end
118
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_tuner_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.6
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SonicGarden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-18 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -248,7 +248,6 @@ files:
248
248
  - spec/support/fake_html_safe_string.rb
249
249
  - spec/support/fake_logger.rb
250
250
  - spec/support/fake_passenger.rb
251
- - spec/support/fake_resque_job.rb
252
251
  - spec/support/fake_unicorn.rb
253
252
  - spec/support/middleware_stack.rb
254
253
  - spec/support/writing_cache.rb
@@ -307,7 +306,6 @@ test_files:
307
306
  - spec/support/fake_html_safe_string.rb
308
307
  - spec/support/fake_logger.rb
309
308
  - spec/support/fake_passenger.rb
310
- - spec/support/fake_resque_job.rb
311
309
  - spec/support/fake_unicorn.rb
312
310
  - spec/support/middleware_stack.rb
313
311
  - spec/support/writing_cache.rb
@@ -1,18 +0,0 @@
1
- class FakeResqueJob
2
- def initialize(&action)
3
- @action = action || lambda {}
4
- end
5
-
6
- def fork_and_perform
7
- fork do
8
- perform
9
- exit!
10
- end
11
- Process.wait
12
- end
13
-
14
- def perform
15
- @action.call
16
- true
17
- end
18
- end