chore-core 4.1.0 → 4.2.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
- SHA1:
3
- metadata.gz: 14cf933fa097e21cefd68a8fb47970cb5e9eb889
4
- data.tar.gz: 9c62d3f54e42359ac069d1d8903a2078b2f59ee9
2
+ SHA256:
3
+ metadata.gz: daa3f5279f93a07ef0291af227bb050b856b513c9128d4780d103372e58b3136
4
+ data.tar.gz: ff73b6ad7bf09039c2e9d2307edacb3abfdce90f43f3f245c51769d9a3a595a4
5
5
  SHA512:
6
- metadata.gz: 42be728df52adca79da1abad05f98259efba767c0100fbd46ad2a83bd2ca777e1c2cc2aa9aafc0c6dbfaff159f622c63b6c55d01bc148bca4a7b9b930833de9c
7
- data.tar.gz: acced3995b2916e36eb4ca5ba0735d57e6e987f80d792de64311576210757d900c58349c0f5d8e56a9619284139437b98f776ece5c985cf06a58ffc509a0ddc4
6
+ metadata.gz: d3d53aba8c2146432a9d257fad873c44aa85681ed803f5ea6c4e3b15ac3d13bc0c60b50d7bd6c5e3e573de6efea5eb37f75c37d9bb4f47781133c6e578db51fb
7
+ data.tar.gz: ea6be89c29d2d96da53958d580ffa16c6e2da4cff53837186ae6a8b8da43130a929ea24d564e7253e375507c0d243b38ff4a473dd05f02105fbc945acd27c1fa
data/README.md CHANGED
@@ -241,6 +241,8 @@ A number of hooks, both global and per-job, exist in Chore for flexibility and c
241
241
  * `on_rejected(message)`
242
242
  * `on_failure(message, error)`
243
243
  * `on_permanent_failure(queue_name, message, error)`
244
+ * `around_publish`
245
+ * `around_perform`
244
246
 
245
247
  All per-job hooks can also be global hooks.
246
248
 
@@ -394,4 +396,4 @@ pgrep -f chore-worker
394
396
 
395
397
  ## Copyright
396
398
 
397
- Copyright (c) 2013 - 2020 Tapjoy. See [LICENSE.txt](LICENSE.txt) for further details.
399
+ Copyright (c) 2013 - 2023 Tapjoy. See [LICENSE.txt](LICENSE.txt) for further details.
data/lib/chore/job.rb CHANGED
@@ -144,7 +144,12 @@ module Chore
144
144
  def perform_async(*args)
145
145
  self.class.run_hooks_for(:before_publish,*args)
146
146
  @chore_publisher ||= self.class.options[:publisher]
147
- @chore_publisher.publish(self.class.prefixed_queue_name,self.class.job_hash(args))
147
+
148
+ publish_job_hash = self.class.job_hash(args)
149
+ Chore.run_hooks_for(:around_publish, self.class.prefixed_queue_name, publish_job_hash) do
150
+ @chore_publisher.publish(self.class.prefixed_queue_name,publish_job_hash)
151
+ end
152
+
148
153
  self.class.run_hooks_for(:after_publish,*args)
149
154
  end
150
155
 
data/lib/chore/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Chore
2
2
  module Version #:nodoc:
3
3
  MAJOR = 4
4
- MINOR = 1
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
 
7
7
  STRING = [ MAJOR, MINOR, PATCH ].join('.')
data/lib/chore/worker.rb CHANGED
@@ -111,7 +111,7 @@ module Chore
111
111
 
112
112
  begin
113
113
  Chore.logger.info { "Running job #{klass} with params #{message}"}
114
- perform_job(klass,message)
114
+ perform_job(klass, message)
115
115
  item.consumer.complete(item.id, item.receipt_handle)
116
116
  Chore.logger.info { "Finished job #{klass} with params #{message}"}
117
117
  klass.run_hooks_for(:after_perform, message)
@@ -149,7 +149,9 @@ module Chore
149
149
  end
150
150
 
151
151
  def perform_job(klass, message)
152
- klass.perform(*options[:payload_handler].payload(message))
152
+ Chore.run_hooks_for(:around_perform, klass, message) do
153
+ klass.perform(*options[:payload_handler].payload(message))
154
+ end
153
155
  end
154
156
  end
155
157
  end
@@ -69,6 +69,14 @@ describe Chore::Job do
69
69
  Chore::Publisher.any_instance.should_receive(:publish).with('test_queue',{:class => 'TestJob',:args => args}).and_return(true)
70
70
  TestJob.perform_async(*args)
71
71
  end
72
+
73
+ it 'calls the around_publish hook with the correct parameters' do
74
+ args = [1,2,{:h => 'ash'}]
75
+ expect(Chore).to receive(:run_hooks_for).with(:around_publish, 'test_queue', {:class => 'TestJob',:args => args}).and_call_original
76
+ TestJob.queue_options(:publisher => Chore::Publisher)
77
+ Chore::Publisher.any_instance.should_receive(:publish).with('test_queue',{:class => 'TestJob',:args => args}).and_return(true)
78
+ TestJob.perform_async(*args)
79
+ end
72
80
  end
73
81
 
74
82
  describe 'publisher configured via Chore.configure' do
@@ -69,6 +69,15 @@ describe Chore::Worker do
69
69
  Chore::Worker.start(work, {:payload_handler => payload_handler})
70
70
  end
71
71
 
72
+ it 'calls the around_perform hook with the correct parameters' do
73
+ expect(Chore).to receive(:run_hooks_for).with(:around_perform, SimpleJob, {"class" => 'SimpleJob', "args" => job_args}).and_call_original
74
+ expect(Chore).to receive(:run_hooks_for).at_least(:once).and_call_original
75
+
76
+ work = Chore::UnitOfWork.new('1', nil, 'test', 60, encoded_job, 0, consumer)
77
+ w = Chore::Worker.new(work, { payload_handler: payload_handler })
78
+ w.start
79
+ end
80
+
72
81
  context 'when the job has a dedupe_lambda defined' do
73
82
  context 'when the value being deduped on is unique' do
74
83
  let(:job_args) { [rand,2,'3'] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chore-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tapjoy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -210,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  - !ruby/object:Gem::Version
211
211
  version: '0'
212
212
  requirements: []
213
- rubyforge_project:
214
- rubygems_version: 2.5.1
213
+ rubygems_version: 3.0.3.1
215
214
  signing_key:
216
215
  specification_version: 4
217
216
  summary: Job processing... for the future!