cloudtasker 0.12.2 → 0.13.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 +4 -4
- data/.github/workflows/lint_rubocop.yml +20 -0
- data/.github/workflows/{test.yml → test_ruby_2.5_2.6.yml} +11 -8
- data/.github/workflows/test_ruby_2.7.yml +44 -0
- data/.github/workflows/test_ruby_3.x.yml +43 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/Appraisals +52 -8
- data/CHANGELOG.md +10 -0
- data/README.md +14 -3
- data/Rakefile +0 -6
- data/cloudtasker.gemspec +1 -6
- data/docs/CRON_JOBS.md +2 -2
- data/gemfiles/google_cloud_tasks_1.0.gemfile +2 -1
- data/gemfiles/google_cloud_tasks_1.1.gemfile +2 -1
- data/gemfiles/google_cloud_tasks_1.2.gemfile +2 -1
- data/gemfiles/google_cloud_tasks_1.3.gemfile +2 -1
- data/gemfiles/google_cloud_tasks_1.4.gemfile +8 -0
- data/gemfiles/google_cloud_tasks_1.5.gemfile +8 -0
- data/gemfiles/google_cloud_tasks_2.0.gemfile +8 -0
- data/gemfiles/google_cloud_tasks_2.1.gemfile +8 -0
- data/gemfiles/rails_5.2.gemfile +1 -0
- data/gemfiles/rails_6.0.gemfile +1 -0
- data/gemfiles/{semantic_logger_4.7.gemfile → rails_6.1.gemfile} +2 -1
- data/gemfiles/rails_7.0.gemfile +8 -0
- data/gemfiles/semantic_logger_3.4.gemfile +1 -0
- data/gemfiles/semantic_logger_4.6.gemfile +1 -0
- data/gemfiles/semantic_logger_4.7.0.gemfile +1 -0
- data/gemfiles/semantic_logger_4.7.2.gemfile +1 -0
- data/lib/cloudtasker/backend/{google_cloud_task.rb → google_cloud_task_v1.rb} +15 -11
- data/lib/cloudtasker/backend/google_cloud_task_v2.rb +210 -0
- data/lib/cloudtasker/backend/memory_task.rb +1 -1
- data/lib/cloudtasker/backend/redis_task.rb +7 -3
- data/lib/cloudtasker/cloud_task.rb +43 -5
- data/lib/cloudtasker/cron/schedule.rb +7 -7
- data/lib/cloudtasker/redis_client.rb +39 -14
- data/lib/cloudtasker/unique_job/job.rb +3 -2
- data/lib/cloudtasker/unique_job/middleware/client.rb +2 -1
- data/lib/cloudtasker/version.rb +1 -1
- data/lib/cloudtasker/worker.rb +3 -3
- data/lib/cloudtasker/worker_wrapper.rb +1 -1
- data/lib/tasks/setup_queue.rake +2 -2
- metadata +19 -77
- data/gemfiles/google_cloud_tasks_1.0.gemfile.lock +0 -342
- data/gemfiles/google_cloud_tasks_1.1.gemfile.lock +0 -342
- data/gemfiles/google_cloud_tasks_1.2.gemfile.lock +0 -342
- data/gemfiles/google_cloud_tasks_1.3.gemfile.lock +0 -343
- data/gemfiles/rails_4.0.gemfile +0 -10
- data/gemfiles/rails_4.1.gemfile +0 -9
- data/gemfiles/rails_4.2.gemfile +0 -9
- data/gemfiles/rails_5.0.gemfile +0 -9
- data/gemfiles/rails_5.1.gemfile +0 -9
- data/gemfiles/rails_5.2.gemfile.lock +0 -327
- data/gemfiles/rails_6.0.gemfile.lock +0 -343
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59faa788a8c1238974bac7f81169c7df4fc460e0b58d181918c7c9b087e6ea29
|
|
4
|
+
data.tar.gz: 106d98dc7571bd65f52774946b5e995f47e7c45be9b54dca41644946cd1c61d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a22f2df22f4b84a330bd613689f63b456cbcc6b87318d1501029e0794cedeb0951e73a7c974e93957c4333a674bdb47a6270995eb81bbe281f5ec5e56009f50
|
|
7
|
+
data.tar.gz: 84120f64e690ebcd06c93890c14278d1797620b1289b05f10a9d6846bff965febc06261aa560b3179315b64d26a1b193d19a65651d6b0b2f6ff46d54e779356f
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Rubocop
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v2
|
|
10
|
+
- uses: zhulik/redis-action@1.1.0
|
|
11
|
+
- name: Set up Ruby
|
|
12
|
+
uses: ruby/setup-ruby@v1
|
|
13
|
+
with:
|
|
14
|
+
ruby-version: '3.0.1'
|
|
15
|
+
bundler-cache: true
|
|
16
|
+
- name: Lint codebase
|
|
17
|
+
run: |
|
|
18
|
+
gem install bundler
|
|
19
|
+
bundle install --jobs 4 --retry 3
|
|
20
|
+
bundle exec rubocop
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Ruby 2.5/2.6
|
|
2
2
|
|
|
3
3
|
on: [push, pull_request]
|
|
4
4
|
|
|
@@ -8,34 +8,37 @@ jobs:
|
|
|
8
8
|
strategy:
|
|
9
9
|
matrix:
|
|
10
10
|
ruby:
|
|
11
|
-
- '2.5.
|
|
12
|
-
- '2.6.
|
|
11
|
+
- '2.5.9'
|
|
12
|
+
- '2.6.7'
|
|
13
13
|
appraisal:
|
|
14
14
|
- 'google-cloud-tasks-1.0'
|
|
15
15
|
- 'google-cloud-tasks-1.1'
|
|
16
16
|
- 'google-cloud-tasks-1.2'
|
|
17
17
|
- 'google-cloud-tasks-1.3'
|
|
18
|
+
- 'google-cloud-tasks-1.4'
|
|
19
|
+
- 'google-cloud-tasks-1.5'
|
|
20
|
+
- 'google-cloud-tasks-2.0'
|
|
21
|
+
- 'google-cloud-tasks-2.1'
|
|
18
22
|
- 'rails-5.2'
|
|
19
23
|
- 'rails-6.0'
|
|
24
|
+
- 'rails-6.1'
|
|
20
25
|
- 'semantic_logger-3.4'
|
|
21
26
|
- 'semantic_logger-4.6'
|
|
22
27
|
- 'semantic_logger-4.7.0'
|
|
23
28
|
- 'semantic_logger-4.7.2'
|
|
24
29
|
steps:
|
|
25
|
-
- name: Setup System
|
|
26
|
-
run: sudo apt-get install libsqlite3-dev
|
|
27
30
|
- uses: actions/checkout@v2
|
|
28
31
|
- uses: zhulik/redis-action@1.1.0
|
|
29
|
-
- name: Set up Ruby
|
|
30
|
-
uses:
|
|
32
|
+
- name: Set up Ruby
|
|
33
|
+
uses: ruby/setup-ruby@v1
|
|
31
34
|
with:
|
|
32
35
|
ruby-version: ${{ matrix.ruby }}
|
|
36
|
+
bundler-cache: true
|
|
33
37
|
- name: Build and test with Rake
|
|
34
38
|
env:
|
|
35
39
|
APPRAISAL_CONTEXT: ${{ matrix.appraisal }}
|
|
36
40
|
run: |
|
|
37
41
|
gem install bundler
|
|
38
42
|
bundle install --jobs 4 --retry 3
|
|
39
|
-
bundle exec rubocop
|
|
40
43
|
bundle exec appraisal ${APPRAISAL_CONTEXT} bundle
|
|
41
44
|
bundle exec appraisal ${APPRAISAL_CONTEXT} rspec
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Ruby 2.7
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
ruby:
|
|
11
|
+
- '2.7.5'
|
|
12
|
+
appraisal:
|
|
13
|
+
- 'google-cloud-tasks-1.0'
|
|
14
|
+
- 'google-cloud-tasks-1.1'
|
|
15
|
+
- 'google-cloud-tasks-1.2'
|
|
16
|
+
- 'google-cloud-tasks-1.3'
|
|
17
|
+
- 'google-cloud-tasks-1.4'
|
|
18
|
+
- 'google-cloud-tasks-1.5'
|
|
19
|
+
- 'google-cloud-tasks-2.0'
|
|
20
|
+
- 'google-cloud-tasks-2.1'
|
|
21
|
+
- 'rails-5.2'
|
|
22
|
+
- 'rails-6.0'
|
|
23
|
+
- 'rails-6.1'
|
|
24
|
+
- 'rails-7.0'
|
|
25
|
+
- 'semantic_logger-3.4'
|
|
26
|
+
- 'semantic_logger-4.6'
|
|
27
|
+
- 'semantic_logger-4.7.0'
|
|
28
|
+
- 'semantic_logger-4.7.2'
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v2
|
|
31
|
+
- uses: zhulik/redis-action@1.1.0
|
|
32
|
+
- name: Set up Ruby
|
|
33
|
+
uses: ruby/setup-ruby@v1
|
|
34
|
+
with:
|
|
35
|
+
ruby-version: ${{ matrix.ruby }}
|
|
36
|
+
bundler-cache: true
|
|
37
|
+
- name: Build and test with Rake
|
|
38
|
+
env:
|
|
39
|
+
APPRAISAL_CONTEXT: ${{ matrix.appraisal }}
|
|
40
|
+
run: |
|
|
41
|
+
gem install bundler
|
|
42
|
+
bundle install --jobs 4 --retry 3
|
|
43
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} bundle
|
|
44
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} rspec
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Ruby 3.x
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
ruby:
|
|
11
|
+
- '3.0.1'
|
|
12
|
+
# - '3.1.0'
|
|
13
|
+
appraisal:
|
|
14
|
+
- 'google-cloud-tasks-1.0'
|
|
15
|
+
- 'google-cloud-tasks-1.1'
|
|
16
|
+
- 'google-cloud-tasks-1.2'
|
|
17
|
+
- 'google-cloud-tasks-1.3'
|
|
18
|
+
- 'google-cloud-tasks-1.4'
|
|
19
|
+
- 'google-cloud-tasks-1.5'
|
|
20
|
+
- 'google-cloud-tasks-2.0'
|
|
21
|
+
- 'google-cloud-tasks-2.1'
|
|
22
|
+
- 'rails-6.1'
|
|
23
|
+
- 'rails-7.0'
|
|
24
|
+
- 'semantic_logger-3.4'
|
|
25
|
+
- 'semantic_logger-4.6'
|
|
26
|
+
- 'semantic_logger-4.7.0'
|
|
27
|
+
- 'semantic_logger-4.7.2'
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v2
|
|
30
|
+
- uses: zhulik/redis-action@1.1.0
|
|
31
|
+
- name: Set up Ruby
|
|
32
|
+
uses: ruby/setup-ruby@v1
|
|
33
|
+
with:
|
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
|
35
|
+
bundler-cache: true
|
|
36
|
+
- name: Build and test with Rake
|
|
37
|
+
env:
|
|
38
|
+
APPRAISAL_CONTEXT: ${{ matrix.appraisal }}
|
|
39
|
+
run: |
|
|
40
|
+
gem install bundler
|
|
41
|
+
bundle install --jobs 4 --retry 3
|
|
42
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} bundle
|
|
43
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -5,6 +5,11 @@ AllCops:
|
|
|
5
5
|
- 'gemfiles/**/*'
|
|
6
6
|
- 'vendor/**/*'
|
|
7
7
|
|
|
8
|
+
# Ruby 3.0: curly braces around last argument has meaning
|
|
9
|
+
# See: https://github.com/rubocop/rubocop/issues/7641
|
|
10
|
+
Style/BracesAroundHashParameters:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
8
13
|
Metrics/ClassLength:
|
|
9
14
|
Max: 200
|
|
10
15
|
|
data/Appraisals
CHANGED
|
@@ -1,41 +1,85 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
appraise 'google-cloud-tasks-1.0' do
|
|
4
|
-
gem '
|
|
4
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
5
|
+
gem 'google-cloud-tasks', '~> 1.0.0'
|
|
5
6
|
end
|
|
6
7
|
|
|
7
8
|
appraise 'google-cloud-tasks-1.1' do
|
|
8
|
-
gem '
|
|
9
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
10
|
+
gem 'google-cloud-tasks', '~> 1.1.0'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
appraise 'google-cloud-tasks-1.2' do
|
|
12
|
-
gem '
|
|
14
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
15
|
+
gem 'google-cloud-tasks', '~> 1.2.0'
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
appraise 'google-cloud-tasks-1.3' do
|
|
16
|
-
gem '
|
|
19
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
20
|
+
gem 'google-cloud-tasks', '~> 1.3.0'
|
|
17
21
|
end
|
|
18
22
|
|
|
19
|
-
appraise '
|
|
20
|
-
gem '
|
|
23
|
+
appraise 'google-cloud-tasks-1.4' do
|
|
24
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
25
|
+
gem 'google-cloud-tasks', '~> 1.4.0'
|
|
21
26
|
end
|
|
22
27
|
|
|
23
|
-
appraise '
|
|
24
|
-
gem '
|
|
28
|
+
appraise 'google-cloud-tasks-1.5' do
|
|
29
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
30
|
+
gem 'google-cloud-tasks', '~> 1.5.0'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
appraise 'google-cloud-tasks-2.0' do
|
|
34
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
35
|
+
gem 'google-cloud-tasks', '~> 2.0.0'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
appraise 'google-cloud-tasks-2.1' do
|
|
39
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
40
|
+
gem 'google-cloud-tasks', '~> 2.1.0'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if RUBY_VERSION < '3'
|
|
44
|
+
appraise 'rails-5.2' do
|
|
45
|
+
gem 'rails', '5.2'
|
|
46
|
+
gem 'rspec-rails'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
appraise 'rails-6.0' do
|
|
50
|
+
gem 'rails', '6.0'
|
|
51
|
+
gem 'rspec-rails'
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
appraise 'rails-6.1' do
|
|
56
|
+
gem 'rails', '6.1'
|
|
57
|
+
gem 'rspec-rails'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if RUBY_VERSION >= '2.7'
|
|
61
|
+
appraise 'rails-7.0' do
|
|
62
|
+
gem 'rails', '7.0'
|
|
63
|
+
gem 'rspec-rails'
|
|
64
|
+
end
|
|
25
65
|
end
|
|
26
66
|
|
|
27
67
|
appraise 'semantic_logger-3.4' do
|
|
68
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
28
69
|
gem 'semantic_logger', '3.4.1'
|
|
29
70
|
end
|
|
30
71
|
|
|
31
72
|
appraise 'semantic_logger-4.6' do
|
|
73
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
32
74
|
gem 'semantic_logger', '4.6.1'
|
|
33
75
|
end
|
|
34
76
|
|
|
35
77
|
appraise 'semantic_logger-4.7.0' do
|
|
78
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
36
79
|
gem 'semantic_logger', '4.7.0'
|
|
37
80
|
end
|
|
38
81
|
|
|
39
82
|
appraise 'semantic_logger-4.7.2' do
|
|
83
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
|
40
84
|
gem 'semantic_logger', '4.7.2'
|
|
41
85
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v0.13.rc2](https://github.com/keypup-io/cloudtasker/tree/v0.13.rc2) (2022-01-25)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/keypup-io/cloudtasker/compare/v0.12.2...v0.13.rc2)
|
|
6
|
+
|
|
7
|
+
**Improvements:**
|
|
8
|
+
- Dependencies: add support for google-cloud-tasks v2 and while keeping backward compatibility with v1. For existing projects, you may need to run `bundle update google-cloud-tasks` after upgrading cloudtasker to update google-cloud-tasks to the latest version.
|
|
9
|
+
- Ruby 3: Rework method arguments to be compatible with Ruby 3
|
|
10
|
+
- Tests: Separate test environment for Ruby 2 and Ruby 3
|
|
11
|
+
- Tests: Do not load Rails by default and skip Rails-specific tests in non-Rails appraisals
|
|
12
|
+
|
|
3
13
|
## [v0.12.2](https://github.com/keypup-io/cloudtasker/tree/v0.12.2) (2021-12-31)
|
|
4
14
|
|
|
5
15
|
[Full Changelog](https://github.com/keypup-io/cloudtasker/compare/v0.12.1...v0.12.2)
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Cloudtasker also provides optional modules for running [cron jobs](docs/CRON_JOB
|
|
|
12
12
|
|
|
13
13
|
A local processing server is also available for development. This local server processes jobs in lieu of Cloud Tasks and allows you to work offline.
|
|
14
14
|
|
|
15
|
-
**Maturity**: This gem is production-ready. We at Keypup have already processed millions of jobs using Cloudtasker and all related extensions (cron, batch and unique jobs). We are planning to release the official `v1.0.0` somewhere in
|
|
15
|
+
**Maturity**: This gem is production-ready. We at Keypup have already processed millions of jobs using Cloudtasker and all related extensions (cron, batch and unique jobs). We are planning to release the official `v1.0.0` somewhere in 2022, in case we've missed any edge-case bug.
|
|
16
16
|
|
|
17
17
|
## Summary
|
|
18
18
|
|
|
@@ -51,6 +51,9 @@ Add this line to your application's Gemfile:
|
|
|
51
51
|
|
|
52
52
|
```ruby
|
|
53
53
|
gem 'cloudtasker'
|
|
54
|
+
|
|
55
|
+
# For Ruby 3 support, please use v0.13.rc1
|
|
56
|
+
gem 'cloudtasker, '~> 0.13.rc1'
|
|
54
57
|
```
|
|
55
58
|
|
|
56
59
|
And then execute:
|
|
@@ -1087,9 +1090,17 @@ To size the concurrency of your queues you should therefore take the most limiti
|
|
|
1087
1090
|
|
|
1088
1091
|
## Development
|
|
1089
1092
|
|
|
1090
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
|
1093
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
|
1094
|
+
|
|
1095
|
+
For tests, run `rake` to run the tests. Note that Rails is not in context by default, which means Rails-specific test will not run.
|
|
1096
|
+
For tests including Rails-specific tests, run `bundle exec appraisal rails-7.0 rake`
|
|
1097
|
+
For all context-specific tests (incl. Rails), run the [appraisal tests](Appraisals) using `bundle exec appraisal rake`.
|
|
1098
|
+
|
|
1099
|
+
You can run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
1100
|
+
|
|
1101
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
1091
1102
|
|
|
1092
|
-
To
|
|
1103
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
1093
1104
|
|
|
1094
1105
|
## Contributing
|
|
1095
1106
|
|
data/Rakefile
CHANGED
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'bundler/gem_tasks'
|
|
4
4
|
require 'rspec/core/rake_task'
|
|
5
|
-
require 'github_changelog_generator/task'
|
|
6
5
|
|
|
7
6
|
RSpec::Core::RakeTask.new(:spec)
|
|
8
7
|
|
|
9
8
|
task default: :spec
|
|
10
|
-
|
|
11
|
-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
|
12
|
-
config.user = 'keypup-io'
|
|
13
|
-
config.project = 'cloudtasker'
|
|
14
|
-
end
|
data/cloudtasker.gemspec
CHANGED
|
@@ -31,14 +31,13 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_dependency 'activesupport'
|
|
32
32
|
spec.add_dependency 'connection_pool'
|
|
33
33
|
spec.add_dependency 'fugit'
|
|
34
|
-
spec.add_dependency 'google-cloud-tasks'
|
|
34
|
+
spec.add_dependency 'google-cloud-tasks'
|
|
35
35
|
spec.add_dependency 'jwt'
|
|
36
36
|
spec.add_dependency 'redis'
|
|
37
37
|
spec.add_dependency 'retriable'
|
|
38
38
|
|
|
39
39
|
spec.add_development_dependency 'appraisal'
|
|
40
40
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
41
|
-
spec.add_development_dependency 'github_changelog_generator'
|
|
42
41
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
|
43
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
44
43
|
spec.add_development_dependency 'rspec-json_expectations', '~> 2.2'
|
|
@@ -47,8 +46,4 @@ Gem::Specification.new do |spec|
|
|
|
47
46
|
spec.add_development_dependency 'semantic_logger'
|
|
48
47
|
spec.add_development_dependency 'timecop'
|
|
49
48
|
spec.add_development_dependency 'webmock'
|
|
50
|
-
|
|
51
|
-
spec.add_development_dependency 'rails'
|
|
52
|
-
spec.add_development_dependency 'rspec-rails'
|
|
53
|
-
spec.add_development_dependency 'sqlite3'
|
|
54
49
|
end
|
data/docs/CRON_JOBS.md
CHANGED
|
@@ -45,12 +45,12 @@ You can maintain the list of cron jobs in a YAML file inside your config folder
|
|
|
45
45
|
# Run job every minute
|
|
46
46
|
some_schedule_name:
|
|
47
47
|
worker: 'SomeCronWorker'
|
|
48
|
-
cron:
|
|
48
|
+
cron: '* * * * *'
|
|
49
49
|
|
|
50
50
|
# Run job every hour on the fifteenth minute
|
|
51
51
|
other_cron_schedule:
|
|
52
52
|
worker: 'OtherCronWorker'
|
|
53
|
-
cron:
|
|
53
|
+
cron: '15 * * * *'
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Then register the jobs inside your Cloudtasker initializer this way:
|
data/gemfiles/rails_5.2.gemfile
CHANGED
data/gemfiles/rails_6.0.gemfile
CHANGED
|
@@ -6,34 +6,38 @@ require 'retriable'
|
|
|
6
6
|
module Cloudtasker
|
|
7
7
|
module Backend
|
|
8
8
|
# Manage tasks pushed to GCP Cloud Task
|
|
9
|
-
class
|
|
9
|
+
class GoogleCloudTaskV1
|
|
10
10
|
attr_accessor :gcp_task
|
|
11
11
|
|
|
12
12
|
#
|
|
13
13
|
# Create the queue configured in Cloudtasker if it does not already exist.
|
|
14
14
|
#
|
|
15
|
-
# @param [String]
|
|
15
|
+
# @param [String] :name The queue name
|
|
16
|
+
# @param [Integer] :concurrency The queue concurrency
|
|
17
|
+
# @param [Integer] :retries The number of retries for the queue
|
|
16
18
|
#
|
|
17
19
|
# @return [Google::Cloud::Tasks::V2beta3::Queue] The queue
|
|
18
20
|
#
|
|
19
|
-
def self.setup_queue(
|
|
21
|
+
def self.setup_queue(name: nil, concurrency: nil, retries: nil)
|
|
20
22
|
# Build full queue path
|
|
21
|
-
queue_name =
|
|
23
|
+
queue_name = name || Cloudtasker::Config::DEFAULT_JOB_QUEUE
|
|
22
24
|
full_queue_name = queue_path(queue_name)
|
|
23
25
|
|
|
24
26
|
# Try to get existing queue
|
|
25
27
|
client.get_queue(full_queue_name)
|
|
26
28
|
rescue Google::Gax::RetryError
|
|
27
29
|
# Extract options
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
queue_concurrency = (concurrency || Cloudtasker::Config::DEFAULT_QUEUE_CONCURRENCY).to_i
|
|
31
|
+
queue_retries = (retries || Cloudtasker::Config::DEFAULT_QUEUE_RETRIES).to_i
|
|
30
32
|
|
|
31
33
|
# Create queue on 'not found' error
|
|
32
34
|
client.create_queue(
|
|
33
35
|
client.location_path(config.gcp_project_id, config.gcp_location_id),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
{
|
|
37
|
+
name: full_queue_name,
|
|
38
|
+
retry_config: { max_attempts: queue_retries },
|
|
39
|
+
rate_limits: { max_concurrent_dispatches: queue_concurrency }
|
|
40
|
+
}
|
|
37
41
|
)
|
|
38
42
|
end
|
|
39
43
|
|
|
@@ -113,7 +117,7 @@ module Cloudtasker
|
|
|
113
117
|
#
|
|
114
118
|
# @param [String] id The task id.
|
|
115
119
|
#
|
|
116
|
-
# @return [Cloudtasker::Backend::
|
|
120
|
+
# @return [Cloudtasker::Backend::GoogleCloudTaskV1, nil] The retrieved task.
|
|
117
121
|
#
|
|
118
122
|
def self.find(id)
|
|
119
123
|
resp = with_gax_retries { client.get_task(id) }
|
|
@@ -128,7 +132,7 @@ module Cloudtasker
|
|
|
128
132
|
#
|
|
129
133
|
# @param [Hash] payload The task payload.
|
|
130
134
|
#
|
|
131
|
-
# @return [Cloudtasker::Backend::
|
|
135
|
+
# @return [Cloudtasker::Backend::GoogleCloudTaskV1, nil] The created task.
|
|
132
136
|
#
|
|
133
137
|
def self.create(payload)
|
|
134
138
|
payload = format_task_payload(payload)
|