cloudtasker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +27 -0
  5. data/.travis.yml +7 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +247 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +43 -0
  11. data/Rakefile +8 -0
  12. data/app/controllers/cloudtasker/application_controller.rb +6 -0
  13. data/app/controllers/cloudtasker/worker_controller.rb +38 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/cloudtasker.gemspec +48 -0
  17. data/config/routes.rb +5 -0
  18. data/lib/cloudtasker.rb +31 -0
  19. data/lib/cloudtasker/authentication_error.rb +6 -0
  20. data/lib/cloudtasker/authenticator.rb +55 -0
  21. data/lib/cloudtasker/batch.rb +5 -0
  22. data/lib/cloudtasker/batch/batch_progress.rb +97 -0
  23. data/lib/cloudtasker/batch/config.rb +11 -0
  24. data/lib/cloudtasker/batch/extension/worker.rb +13 -0
  25. data/lib/cloudtasker/batch/job.rb +320 -0
  26. data/lib/cloudtasker/batch/middleware.rb +24 -0
  27. data/lib/cloudtasker/batch/middleware/server.rb +14 -0
  28. data/lib/cloudtasker/config.rb +122 -0
  29. data/lib/cloudtasker/cron.rb +5 -0
  30. data/lib/cloudtasker/cron/config.rb +11 -0
  31. data/lib/cloudtasker/cron/job.rb +207 -0
  32. data/lib/cloudtasker/cron/middleware.rb +21 -0
  33. data/lib/cloudtasker/cron/middleware/server.rb +14 -0
  34. data/lib/cloudtasker/cron/schedule.rb +227 -0
  35. data/lib/cloudtasker/engine.rb +20 -0
  36. data/lib/cloudtasker/invalid_worker_error.rb +6 -0
  37. data/lib/cloudtasker/meta_store.rb +86 -0
  38. data/lib/cloudtasker/middleware/chain.rb +250 -0
  39. data/lib/cloudtasker/redis_client.rb +115 -0
  40. data/lib/cloudtasker/task.rb +175 -0
  41. data/lib/cloudtasker/unique_job.rb +5 -0
  42. data/lib/cloudtasker/unique_job/config.rb +10 -0
  43. data/lib/cloudtasker/unique_job/conflict_strategy/base_strategy.rb +37 -0
  44. data/lib/cloudtasker/unique_job/conflict_strategy/raise.rb +28 -0
  45. data/lib/cloudtasker/unique_job/conflict_strategy/reject.rb +11 -0
  46. data/lib/cloudtasker/unique_job/conflict_strategy/reschedule.rb +30 -0
  47. data/lib/cloudtasker/unique_job/job.rb +136 -0
  48. data/lib/cloudtasker/unique_job/lock/base_lock.rb +70 -0
  49. data/lib/cloudtasker/unique_job/lock/no_op.rb +11 -0
  50. data/lib/cloudtasker/unique_job/lock/until_executed.rb +34 -0
  51. data/lib/cloudtasker/unique_job/lock/until_executing.rb +30 -0
  52. data/lib/cloudtasker/unique_job/lock/while_executing.rb +23 -0
  53. data/lib/cloudtasker/unique_job/lock_error.rb +8 -0
  54. data/lib/cloudtasker/unique_job/middleware.rb +36 -0
  55. data/lib/cloudtasker/unique_job/middleware/client.rb +14 -0
  56. data/lib/cloudtasker/unique_job/middleware/server.rb +14 -0
  57. data/lib/cloudtasker/version.rb +5 -0
  58. data/lib/cloudtasker/worker.rb +211 -0
  59. metadata +286 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac6e1474db922e6509a54912fb42d5522c066c7926c0bb0c45e4eec80335c83c
4
+ data.tar.gz: af4b423e1ed2d17fdd9c1228f34a965ac8d17078f96331d01b64bc3766f3fbef
5
+ SHA512:
6
+ metadata.gz: 669d907248880e4de8f8a1d0ab83aad96540d93bf3b70dec804184b5a0507244a891e5d66f03593163d6e581a85ad1686e348ac3413b4c250512a5ec877c9209
7
+ data.tar.gz: 2b6a09ff60f5105f167c818dcf284881afbbd96a4818a9e1fc432c8fd8ee19014127e6292bb5749c09f4a10458cbecd94c48b0f8486e4f8fed91dbf7d3f36772
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/dummy/log/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,27 @@
1
+ require: rubocop-rspec
2
+
3
+ Metrics/ClassLength:
4
+ Max: 150
5
+
6
+ Metrics/AbcSize:
7
+ Max: 20
8
+
9
+ Metrics/LineLength:
10
+ Max: 120
11
+
12
+ Metrics/MethodLength:
13
+ Max: 20
14
+
15
+ RSpec/ExpectInHook:
16
+ Enabled: false
17
+
18
+ RSpec/EmptyLineAfterHook:
19
+ Enabled: false
20
+
21
+ RSpec/ScatteredSetup:
22
+ Enabled: false
23
+
24
+ Metrics/BlockLength:
25
+ Exclude:
26
+ - cloudtasker.gemspec
27
+ - 'spec/**/*'
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.5
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at arnaud.lachaume@maestrano.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in cloudtasker.gemspec
6
+ gemspec
@@ -0,0 +1,247 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cloudtasker (0.1.0)
5
+ fugit
6
+ google-cloud-tasks
7
+ jwt
8
+ redis
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actioncable (6.0.0)
14
+ actionpack (= 6.0.0)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (6.0.0)
18
+ actionpack (= 6.0.0)
19
+ activejob (= 6.0.0)
20
+ activerecord (= 6.0.0)
21
+ activestorage (= 6.0.0)
22
+ activesupport (= 6.0.0)
23
+ mail (>= 2.7.1)
24
+ actionmailer (6.0.0)
25
+ actionpack (= 6.0.0)
26
+ actionview (= 6.0.0)
27
+ activejob (= 6.0.0)
28
+ mail (~> 2.5, >= 2.5.4)
29
+ rails-dom-testing (~> 2.0)
30
+ actionpack (6.0.0)
31
+ actionview (= 6.0.0)
32
+ activesupport (= 6.0.0)
33
+ rack (~> 2.0)
34
+ rack-test (>= 0.6.3)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.0.0)
38
+ actionpack (= 6.0.0)
39
+ activerecord (= 6.0.0)
40
+ activestorage (= 6.0.0)
41
+ activesupport (= 6.0.0)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.0.0)
44
+ activesupport (= 6.0.0)
45
+ builder (~> 3.1)
46
+ erubi (~> 1.4)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.0.0)
50
+ activesupport (= 6.0.0)
51
+ globalid (>= 0.3.6)
52
+ activemodel (6.0.0)
53
+ activesupport (= 6.0.0)
54
+ activerecord (6.0.0)
55
+ activemodel (= 6.0.0)
56
+ activesupport (= 6.0.0)
57
+ activestorage (6.0.0)
58
+ actionpack (= 6.0.0)
59
+ activejob (= 6.0.0)
60
+ activerecord (= 6.0.0)
61
+ marcel (~> 0.3.1)
62
+ activesupport (6.0.0)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 0.7, < 2)
65
+ minitest (~> 5.1)
66
+ tzinfo (~> 1.1)
67
+ zeitwerk (~> 2.1, >= 2.1.8)
68
+ addressable (2.7.0)
69
+ public_suffix (>= 2.0.2, < 5.0)
70
+ ast (2.4.0)
71
+ builder (3.2.3)
72
+ concurrent-ruby (1.1.5)
73
+ crass (1.0.5)
74
+ diff-lcs (1.3)
75
+ erubi (1.9.0)
76
+ et-orbi (1.2.2)
77
+ tzinfo
78
+ faraday (0.17.0)
79
+ multipart-post (>= 1.2, < 3)
80
+ fugit (1.3.3)
81
+ et-orbi (~> 1.1, >= 1.1.8)
82
+ raabro (~> 1.1)
83
+ globalid (0.4.2)
84
+ activesupport (>= 4.2.0)
85
+ google-cloud-tasks (1.2.0)
86
+ google-gax (~> 1.8)
87
+ googleapis-common-protos (>= 1.3.9, < 2.0)
88
+ grpc-google-iam-v1 (~> 0.6.9)
89
+ google-gax (1.8.1)
90
+ google-protobuf (~> 3.9)
91
+ googleapis-common-protos (>= 1.3.9, < 2.0)
92
+ googleauth (~> 0.9)
93
+ grpc (~> 1.24)
94
+ rly (~> 0.2.3)
95
+ google-protobuf (3.10.1-universal-darwin)
96
+ googleapis-common-protos (1.3.9)
97
+ google-protobuf (~> 3.0)
98
+ googleapis-common-protos-types (~> 1.0)
99
+ grpc (~> 1.0)
100
+ googleapis-common-protos-types (1.0.4)
101
+ google-protobuf (~> 3.0)
102
+ googleauth (0.10.0)
103
+ faraday (~> 0.12)
104
+ jwt (>= 1.4, < 3.0)
105
+ memoist (~> 0.16)
106
+ multi_json (~> 1.11)
107
+ os (>= 0.9, < 2.0)
108
+ signet (~> 0.12)
109
+ grpc (1.24.0-universal-darwin)
110
+ google-protobuf (~> 3.8)
111
+ googleapis-common-protos-types (~> 1.0)
112
+ grpc-google-iam-v1 (0.6.9)
113
+ googleapis-common-protos (>= 1.3.1, < 2.0)
114
+ grpc (~> 1.0)
115
+ i18n (1.7.0)
116
+ concurrent-ruby (~> 1.0)
117
+ jaro_winkler (1.5.4)
118
+ jwt (2.2.1)
119
+ loofah (2.3.1)
120
+ crass (~> 1.0.2)
121
+ nokogiri (>= 1.5.9)
122
+ mail (2.7.1)
123
+ mini_mime (>= 0.1.1)
124
+ marcel (0.3.3)
125
+ mimemagic (~> 0.3.2)
126
+ memoist (0.16.0)
127
+ method_source (0.9.2)
128
+ mimemagic (0.3.3)
129
+ mini_mime (1.0.2)
130
+ mini_portile2 (2.4.0)
131
+ minitest (5.13.0)
132
+ multi_json (1.14.1)
133
+ multipart-post (2.1.1)
134
+ nio4r (2.5.2)
135
+ nokogiri (1.10.5)
136
+ mini_portile2 (~> 2.4.0)
137
+ os (1.0.1)
138
+ parallel (1.18.0)
139
+ parser (2.6.5.0)
140
+ ast (~> 2.4.0)
141
+ public_suffix (4.0.1)
142
+ raabro (1.1.6)
143
+ rack (2.0.7)
144
+ rack-test (1.1.0)
145
+ rack (>= 1.0, < 3)
146
+ rails (6.0.0)
147
+ actioncable (= 6.0.0)
148
+ actionmailbox (= 6.0.0)
149
+ actionmailer (= 6.0.0)
150
+ actionpack (= 6.0.0)
151
+ actiontext (= 6.0.0)
152
+ actionview (= 6.0.0)
153
+ activejob (= 6.0.0)
154
+ activemodel (= 6.0.0)
155
+ activerecord (= 6.0.0)
156
+ activestorage (= 6.0.0)
157
+ activesupport (= 6.0.0)
158
+ bundler (>= 1.3.0)
159
+ railties (= 6.0.0)
160
+ sprockets-rails (>= 2.0.0)
161
+ rails-dom-testing (2.0.3)
162
+ activesupport (>= 4.2.0)
163
+ nokogiri (>= 1.6)
164
+ rails-html-sanitizer (1.3.0)
165
+ loofah (~> 2.3)
166
+ railties (6.0.0)
167
+ actionpack (= 6.0.0)
168
+ activesupport (= 6.0.0)
169
+ method_source
170
+ rake (>= 0.8.7)
171
+ thor (>= 0.20.3, < 2.0)
172
+ rainbow (3.0.0)
173
+ rake (10.5.0)
174
+ redis (4.1.3)
175
+ rly (0.2.3)
176
+ rspec (3.9.0)
177
+ rspec-core (~> 3.9.0)
178
+ rspec-expectations (~> 3.9.0)
179
+ rspec-mocks (~> 3.9.0)
180
+ rspec-core (3.9.0)
181
+ rspec-support (~> 3.9.0)
182
+ rspec-expectations (3.9.0)
183
+ diff-lcs (>= 1.2.0, < 2.0)
184
+ rspec-support (~> 3.9.0)
185
+ rspec-mocks (3.9.0)
186
+ diff-lcs (>= 1.2.0, < 2.0)
187
+ rspec-support (~> 3.9.0)
188
+ rspec-rails (3.9.0)
189
+ actionpack (>= 3.0)
190
+ activesupport (>= 3.0)
191
+ railties (>= 3.0)
192
+ rspec-core (~> 3.9.0)
193
+ rspec-expectations (~> 3.9.0)
194
+ rspec-mocks (~> 3.9.0)
195
+ rspec-support (~> 3.9.0)
196
+ rspec-support (3.9.0)
197
+ rubocop (0.76.0)
198
+ jaro_winkler (~> 1.5.1)
199
+ parallel (~> 1.10)
200
+ parser (>= 2.6)
201
+ rainbow (>= 2.2.2, < 4.0)
202
+ ruby-progressbar (~> 1.7)
203
+ unicode-display_width (>= 1.4.0, < 1.7)
204
+ rubocop-rspec (1.36.0)
205
+ rubocop (>= 0.68.1)
206
+ ruby-progressbar (1.10.1)
207
+ signet (0.12.0)
208
+ addressable (~> 2.3)
209
+ faraday (~> 0.9)
210
+ jwt (>= 1.5, < 3.0)
211
+ multi_json (~> 1.10)
212
+ sprockets (4.0.0)
213
+ concurrent-ruby (~> 1.0)
214
+ rack (> 1, < 3)
215
+ sprockets-rails (3.2.1)
216
+ actionpack (>= 4.0)
217
+ activesupport (>= 4.0)
218
+ sprockets (>= 3.0.0)
219
+ sqlite3 (1.4.0)
220
+ thor (0.20.3)
221
+ thread_safe (0.3.6)
222
+ timecop (0.9.1)
223
+ tzinfo (1.2.5)
224
+ thread_safe (~> 0.1)
225
+ unicode-display_width (1.6.0)
226
+ websocket-driver (0.7.1)
227
+ websocket-extensions (>= 0.1.0)
228
+ websocket-extensions (0.1.4)
229
+ zeitwerk (2.2.1)
230
+
231
+ PLATFORMS
232
+ ruby
233
+
234
+ DEPENDENCIES
235
+ bundler (~> 2.0)
236
+ cloudtasker!
237
+ rails
238
+ rake (~> 10.0)
239
+ rspec (~> 3.0)
240
+ rspec-rails
241
+ rubocop (= 0.76.0)
242
+ rubocop-rspec
243
+ sqlite3
244
+ timecop
245
+
246
+ BUNDLED WITH
247
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Arnaud Lachaume
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Cloudtasker
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cloudtasker`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cloudtasker'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cloudtasker
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/alachaum/cloudtasker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Cloudtasker project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/alachaum/cloudtasker/blob/master/CODE_OF_CONDUCT.md).