cloudtasker 0.10.0 → 0.10.1
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 +4 -4
- data/.github/workflows/test.yml +4 -0
- data/Appraisals +16 -0
- data/CHANGELOG.md +7 -4
- data/README.md +50 -29
- data/cloudtasker.gemspec +1 -0
- data/gemfiles/semantic_logger_3.4.gemfile +7 -0
- data/gemfiles/semantic_logger_4.6.gemfile +7 -0
- data/gemfiles/semantic_logger_4.7.0.gemfile +7 -0
- data/gemfiles/semantic_logger_4.7.2.gemfile +7 -0
- data/gemfiles/semantic_logger_4.7.gemfile +7 -0
- data/lib/cloudtasker/backend/memory_task.rb +3 -0
- data/lib/cloudtasker/version.rb +1 -1
- data/lib/cloudtasker/worker.rb +15 -1
- data/lib/cloudtasker/worker_logger.rb +1 -1
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0f76715e1b778b035aba4e5bd6175b7d632bb114dcaa471f79e6be29013933e
|
4
|
+
data.tar.gz: 8d059110a3e90b04375410b7030d4773ea34d2cc8da0ac89cad20ba146939080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e33bd5cd5587baf20336445833938fcc01e12fa6f43f0236bcb90cf4f8fb8463545f89bca85f3511d95db8b0c05d4bcfe83f94b9a7da3ec2dca51f5f64e660
|
7
|
+
data.tar.gz: 7ac3e128edfd635b543160391b38bcb7acc840aa306cc6713e7f9aa5cd76ea01da3616d293f7f9222496449419392ac2d644bcd643315cd75661a93b1577ac0f
|
data/.github/workflows/test.yml
CHANGED
@@ -21,6 +21,10 @@ jobs:
|
|
21
21
|
- 'google-cloud-tasks-1.3'
|
22
22
|
- 'rails-5.2'
|
23
23
|
- 'rails-6.0'
|
24
|
+
- 'semantic_logger-3.4'
|
25
|
+
- 'semantic_logger-4.6'
|
26
|
+
- 'semantic_logger-4.7.0'
|
27
|
+
- 'semantic_logger-4.7.2'
|
24
28
|
steps:
|
25
29
|
- name: Setup System
|
26
30
|
run: sudo apt-get install libsqlite3-dev
|
data/Appraisals
CHANGED
@@ -23,3 +23,19 @@ end
|
|
23
23
|
appraise 'rails-6.0' do
|
24
24
|
gem 'rails', '6.0'
|
25
25
|
end
|
26
|
+
|
27
|
+
appraise 'semantic_logger-3.4' do
|
28
|
+
gem 'semantic_logger', '3.4.1'
|
29
|
+
end
|
30
|
+
|
31
|
+
appraise 'semantic_logger-4.6' do
|
32
|
+
gem 'semantic_logger', '4.6.1'
|
33
|
+
end
|
34
|
+
|
35
|
+
appraise 'semantic_logger-4.7.0' do
|
36
|
+
gem 'semantic_logger', '4.7.0'
|
37
|
+
end
|
38
|
+
|
39
|
+
appraise 'semantic_logger-4.7.2' do
|
40
|
+
gem 'semantic_logger', '4.7.2'
|
41
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.10.1](https://github.com/keypup-io/cloudtasker/tree/v0.10.1) (2020-10-05)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/keypup-io/cloudtasker/compare/v0.10.0...v0.10.1)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
- Logging: fix log processing with `semantic_logger` `v4.7.2`. Accept any args on block passed to the logger.
|
9
|
+
|
3
10
|
## [v0.10.0](https://github.com/keypup-io/cloudtasker/tree/v0.10.0) (2020-09-02)
|
4
11
|
|
5
12
|
[Full Changelog](https://github.com/keypup-io/cloudtasker/compare/v0.9.3...v0.10.0)
|
@@ -96,7 +103,3 @@ For Sinatra applications please update your Cloudtasker controller according to
|
|
96
103
|
## [v0.1.0](https://github.com/keypup-io/cloudtasker/tree/v0.1.0) (2019-11-17)
|
97
104
|
|
98
105
|
[Full Changelog](https://github.com/keypup-io/cloudtasker/compare/c137feb1ceaaaa4e2fecac0d1f0b4c73151ae002...v0.1.0)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/README.md
CHANGED
@@ -75,7 +75,7 @@ Cloudtasker.configure do |config|
|
|
75
75
|
# Adapt the server port to be the one used by your Rails web process
|
76
76
|
#
|
77
77
|
config.processor_host = 'http://localhost:3000'
|
78
|
-
|
78
|
+
|
79
79
|
#
|
80
80
|
# If you do not have any Rails secret_key_base defined, uncomment the following
|
81
81
|
# This secret is used to authenticate jobs sent to the processing endpoint
|
@@ -158,14 +158,14 @@ The gem can be configured through an initializer. See below all the available co
|
|
158
158
|
Cloudtasker.configure do |config|
|
159
159
|
#
|
160
160
|
# If you do not have any Rails secret_key_base defined, uncomment the following.
|
161
|
-
# This secret is used to authenticate jobs sent to the processing endpoint
|
161
|
+
# This secret is used to authenticate jobs sent to the processing endpoint
|
162
162
|
# of your application.
|
163
163
|
#
|
164
164
|
# Default with Rails: Rails.application.credentials.secret_key_base
|
165
165
|
#
|
166
166
|
# config.secret = 'some-long-token'
|
167
167
|
|
168
|
-
#
|
168
|
+
#
|
169
169
|
# Specify the details of your Google Cloud Task location.
|
170
170
|
#
|
171
171
|
# This not required in development using the Cloudtasker local server.
|
@@ -189,21 +189,21 @@ Cloudtasker.configure do |config|
|
|
189
189
|
#
|
190
190
|
# Specific queues can be created in Cloud Tasks using the gcloud SDK or
|
191
191
|
# via the `rake cloudtasker:setup_queue name=<queue_name>` task.
|
192
|
-
#
|
192
|
+
#
|
193
193
|
config.gcp_queue_prefix = 'my-app'
|
194
194
|
|
195
|
-
#
|
195
|
+
#
|
196
196
|
# Specify the publicly accessible host for your application
|
197
197
|
#
|
198
198
|
# > E.g. in development, using the cloudtasker local server
|
199
199
|
# config.processor_host = 'http://localhost:3000'
|
200
|
-
#
|
200
|
+
#
|
201
201
|
# > E.g. in development, using `config.mode = :production` and ngrok
|
202
202
|
# config.processor_host = 'https://111111.ngrok.io'
|
203
203
|
#
|
204
204
|
config.processor_host = 'https://app.mydomain.com'
|
205
205
|
|
206
|
-
#
|
206
|
+
#
|
207
207
|
# Specify the mode of operation:
|
208
208
|
# - :development => jobs will be pushed to Redis and picked up by the Cloudtasker local server
|
209
209
|
# - :production => jobs will be pushed to Google Cloud Tasks. Requires a publicly accessible domain.
|
@@ -212,20 +212,20 @@ Cloudtasker.configure do |config|
|
|
212
212
|
#
|
213
213
|
# config.mode = Rails.env.production? || Rails.env.my_other_env? ? :production : :development
|
214
214
|
|
215
|
-
#
|
215
|
+
#
|
216
216
|
# Specify the logger to use
|
217
|
-
#
|
217
|
+
#
|
218
218
|
# Default with Rails: Rails.logger
|
219
219
|
# Default without Rails: Logger.new(STDOUT)
|
220
|
-
#
|
220
|
+
#
|
221
221
|
# config.logger = MyLogger.new(STDOUT)
|
222
222
|
|
223
|
-
#
|
223
|
+
#
|
224
224
|
# Specify how many retries are allowed on jobs. This number of retries excludes any
|
225
225
|
# connectivity error due to the application being down or unreachable.
|
226
|
-
#
|
226
|
+
#
|
227
227
|
# Default: 25
|
228
|
-
#
|
228
|
+
#
|
229
229
|
# config.max_retries = 10
|
230
230
|
|
231
231
|
#
|
@@ -262,7 +262,7 @@ Cloudtasker.configure do |config|
|
|
262
262
|
end
|
263
263
|
```
|
264
264
|
|
265
|
-
If the default queue `<gcp_queue_prefix>-default` does not exist in Cloud Tasks you should [create it using the gcloud sdk](https://cloud.google.com/tasks/docs/creating-queues).
|
265
|
+
If the default queue `<gcp_queue_prefix>-default` does not exist in Cloud Tasks you should [create it using the gcloud sdk](https://cloud.google.com/tasks/docs/creating-queues).
|
266
266
|
|
267
267
|
Alternatively with Rails you can simply run the following rake task if you have queue admin permissions (`cloudtasks.queues.get` and `cloudtasks.queues.create`).
|
268
268
|
```bash
|
@@ -364,7 +364,7 @@ CriticalWorker.schedule(args: [1], queue: :important)
|
|
364
364
|
Cloudtasker comes with three optional features:
|
365
365
|
- Cron Jobs [[docs](docs/CRON_JOBS.md)]: Run jobs at fixed intervals.
|
366
366
|
- Batch Jobs [[docs](docs/BATCH_JOBS.md)]: Run jobs in jobs and track completion of the overall batch.
|
367
|
-
- Unique Jobs [[docs](docs/UNIQUE_JOBS.md)]: Ensure uniqueness of jobs based on job arguments.
|
367
|
+
- Unique Jobs [[docs](docs/UNIQUE_JOBS.md)]: Ensure uniqueness of jobs based on job arguments.
|
368
368
|
|
369
369
|
## Working locally
|
370
370
|
|
@@ -381,9 +381,9 @@ You can configure your application to use the Cloudtasker local server using the
|
|
381
381
|
|
382
382
|
Cloudtasker.configure do |config|
|
383
383
|
# ... other options
|
384
|
-
|
384
|
+
|
385
385
|
# Push jobs to redis and let the Cloudtasker local server collect them
|
386
|
-
# This is the default mode unless CLOUDTASKER_ENV or RAILS_ENV or RACK_ENV is set
|
386
|
+
# This is the default mode unless CLOUDTASKER_ENV or RAILS_ENV or RACK_ENV is set
|
387
387
|
# to a non-development environment
|
388
388
|
config.mode = :development
|
389
389
|
end
|
@@ -427,7 +427,7 @@ Cloudtasker.configure do |config|
|
|
427
427
|
|
428
428
|
# Use your ngrok domain as the processor host
|
429
429
|
config.processor_host = 'https://your-tunnel-id.ngrok.io'
|
430
|
-
|
430
|
+
|
431
431
|
# Force Cloudtasker to use Google Cloud Tasks in development
|
432
432
|
config.mode = :production
|
433
433
|
end
|
@@ -578,19 +578,17 @@ E.g. Set max number of retries globally via the cloudtasker initializer.
|
|
578
578
|
# config/initializers/cloudtasker.rb
|
579
579
|
|
580
580
|
Cloudtasker.configure do |config|
|
581
|
-
#
|
581
|
+
#
|
582
582
|
# Specify how many retries are allowed on jobs. This number of retries excludes any
|
583
583
|
# connectivity error that would be due to the application being down or unreachable.
|
584
|
-
#
|
584
|
+
#
|
585
585
|
# Default: 25
|
586
|
-
#
|
586
|
+
#
|
587
587
|
config.max_retries = 10
|
588
588
|
end
|
589
589
|
```
|
590
590
|
|
591
591
|
E.g. Set max number of retries to 3 on a given worker
|
592
|
-
|
593
|
-
E.g.
|
594
592
|
```ruby
|
595
593
|
# app/workers/some_error_worker.rb
|
596
594
|
|
@@ -600,7 +598,30 @@ class SomeErrorWorker
|
|
600
598
|
# This will override the global setting
|
601
599
|
cloudtasker_options max_retries: 3
|
602
600
|
|
603
|
-
def perform
|
601
|
+
def perform
|
602
|
+
raise(ArgumentError)
|
603
|
+
end
|
604
|
+
end
|
605
|
+
```
|
606
|
+
|
607
|
+
E.g. Evaluate the number of max retries at runtime (target: v0.11.0)
|
608
|
+
```ruby
|
609
|
+
# app/workers/some_error_worker.rb
|
610
|
+
|
611
|
+
class SomeErrorWorker
|
612
|
+
include Cloudtasker::Worker
|
613
|
+
|
614
|
+
# Return the number of max retries based on
|
615
|
+
# worker arguments.
|
616
|
+
#
|
617
|
+
# If this method returns nil then max_retries
|
618
|
+
# will delegate to the class `max_retries` setting or Cloudtasker
|
619
|
+
# `max_retries` configuration otion.
|
620
|
+
def max_retries(arg1, arg2)
|
621
|
+
arg1 == 'foo' ? 13 : nil
|
622
|
+
end
|
623
|
+
|
624
|
+
def perform(arg1, arg2)
|
604
625
|
raise(ArgumentError)
|
605
626
|
end
|
606
627
|
end
|
@@ -618,7 +639,7 @@ require 'cloudtasker/testing'
|
|
618
639
|
# Mode 1 (default): Push jobs to Google Cloud Tasks (env != development) or Redis (env == development)
|
619
640
|
Cloudtasker::Testing.enable!
|
620
641
|
|
621
|
-
# Mode 2: Push jobs to an in-memory queue. Jobs will not be processed until you call
|
642
|
+
# Mode 2: Push jobs to an in-memory queue. Jobs will not be processed until you call
|
622
643
|
# Cloudtasker::Worker.drain_all (process all jobs) or MyWorker.drain (process jobs for specific worker)
|
623
644
|
Cloudtasker::Testing.fake!
|
624
645
|
|
@@ -682,9 +703,9 @@ Below are examples of rspec tests. It is assumed that `Cloudtasker::Testing.fake
|
|
682
703
|
**Example 1**: Testing that a job is scheduled
|
683
704
|
```ruby
|
684
705
|
describe 'worker scheduling'
|
685
|
-
subject(:enqueue_job) { MyWorker.perform_async(1,2) }
|
686
|
-
|
687
|
-
it { expect { enqueue_job }.to change(MyWorker.jobs, :size).by(1) }
|
706
|
+
subject(:enqueue_job) { MyWorker.perform_async(1,2) }
|
707
|
+
|
708
|
+
it { expect { enqueue_job }.to change(MyWorker.jobs, :size).by(1) }
|
688
709
|
end
|
689
710
|
```
|
690
711
|
|
@@ -692,7 +713,7 @@ end
|
|
692
713
|
```ruby
|
693
714
|
describe 'worker calls api'
|
694
715
|
subject { Cloudtasker::Testing.inline! { MyApiWorker.perform_async(1,2) } }
|
695
|
-
|
716
|
+
|
696
717
|
before { expect(MyApi).to receive(:fetch).and_return([]) }
|
697
718
|
it { is_expected.to be_truthy }
|
698
719
|
end
|
data/cloudtasker.gemspec
CHANGED
@@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
44
44
|
spec.add_development_dependency 'rubocop', '0.76.0'
|
45
45
|
spec.add_development_dependency 'rubocop-rspec', '1.37.0'
|
46
|
+
spec.add_development_dependency 'semantic_logger'
|
46
47
|
spec.add_development_dependency 'timecop'
|
47
48
|
spec.add_development_dependency 'webmock'
|
48
49
|
|
@@ -166,6 +166,9 @@ module Cloudtasker
|
|
166
166
|
# Delete task
|
167
167
|
self.class.delete(id)
|
168
168
|
resp
|
169
|
+
rescue DeadWorkerError => e
|
170
|
+
self.class.delete(id)
|
171
|
+
raise(e) if self.class.inline_mode?
|
169
172
|
rescue StandardError => e
|
170
173
|
self.job_retries += 1
|
171
174
|
raise(e) if self.class.inline_mode?
|
data/lib/cloudtasker/version.rb
CHANGED
data/lib/cloudtasker/worker.rb
CHANGED
@@ -296,6 +296,20 @@ module Cloudtasker
|
|
296
296
|
other.is_a?(self.class) && other.job_id == job_id
|
297
297
|
end
|
298
298
|
|
299
|
+
#
|
300
|
+
# Return the max number of retries allowed for this job.
|
301
|
+
#
|
302
|
+
# The order of precedence for retry lookup is:
|
303
|
+
# - Worker `max_retries` method
|
304
|
+
# - Class `max_retries` option
|
305
|
+
# - Cloudtasker `max_retries` config option
|
306
|
+
#
|
307
|
+
# @return [Integer] The number of retries
|
308
|
+
#
|
309
|
+
def job_max_retries
|
310
|
+
@job_max_retries ||= (try(:max_retries, *job_args) || self.class.max_retries)
|
311
|
+
end
|
312
|
+
|
299
313
|
#
|
300
314
|
# Return true if the job has excceeded its maximum number
|
301
315
|
# of retries
|
@@ -303,7 +317,7 @@ module Cloudtasker
|
|
303
317
|
# @return [Boolean] True if the job is dead
|
304
318
|
#
|
305
319
|
def job_dead?
|
306
|
-
job_retries >=
|
320
|
+
job_retries >= job_max_retries
|
307
321
|
end
|
308
322
|
|
309
323
|
#
|
@@ -142,7 +142,7 @@ module Cloudtasker
|
|
142
142
|
#
|
143
143
|
def log_message(level, msg, &block)
|
144
144
|
# Merge log-specific context into worker-specific context
|
145
|
-
payload_block = -> { log_block.call.merge(block&.call || {}) }
|
145
|
+
payload_block = ->(*_args) { log_block.call.merge(block&.call || {}) }
|
146
146
|
|
147
147
|
# ActiveSupport::Logger does not support passing a payload through a block on top
|
148
148
|
# of a message.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudtasker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Lachaume
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - '='
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: 1.37.0
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: semantic_logger
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: timecop
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -324,6 +338,11 @@ files:
|
|
324
338
|
- gemfiles/rails_5.2.gemfile.lock
|
325
339
|
- gemfiles/rails_6.0.gemfile
|
326
340
|
- gemfiles/rails_6.0.gemfile.lock
|
341
|
+
- gemfiles/semantic_logger_3.4.gemfile
|
342
|
+
- gemfiles/semantic_logger_4.6.gemfile
|
343
|
+
- gemfiles/semantic_logger_4.7.0.gemfile
|
344
|
+
- gemfiles/semantic_logger_4.7.2.gemfile
|
345
|
+
- gemfiles/semantic_logger_4.7.gemfile
|
327
346
|
- lib/cloudtasker.rb
|
328
347
|
- lib/cloudtasker/authentication_error.rb
|
329
348
|
- lib/cloudtasker/authenticator.rb
|