rails-cloud-tasks 0.0.4rc2 → 0.0.4

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: febc18d459ee7372959661d7fdf6361700deeb6777663049f1ec3c3cadd9519a
4
- data.tar.gz: c5f01e5ab5f4c42d923de94e6e94a04cb36d7e3c46905eec51f74f5f77689869
3
+ metadata.gz: 4ab8eda2821b2bba5e155d3444c4cdf5fca633dd468753f4d177354e6ec1207b
4
+ data.tar.gz: 71a5080bcc0693ea95b68b416246da57e671d7fb24d3bc46a95a895e96c521a5
5
5
  SHA512:
6
- metadata.gz: fa9a92c2aa4bb52b64d327b86d18b0fa421f487f396858ad2a03c5735441ecd5402b2da7923c30938962c2d743bb93ce366bb26db04f79c5b8951d5f9d96abac
7
- data.tar.gz: c882b97485494659e62ddca4855f64899b1629e27ae1714f861c754d8e78dbadbfde69bff0d9487dd47da62c88422acdf46cf1250efefe4e50c06f4bb9394d5b
6
+ metadata.gz: f4ed01e0744ec482ad3d3015f92b35eee118601b1d95b7e7d5e3d030a1ff5f243224f35c527574aa8f3a6e8470fab3f2981fd39607e3f4456601501dfeb636b3
7
+ data.tar.gz: 33b16e211328e0123c85381640087b2d4e1cfca7c0a0fdab0e7777cd20fb3dc148892762eebbf4ec269751b2bf0edb6c1b1f7f2e978962e8ba0d92012e05205c
data/README.md CHANGED
@@ -105,23 +105,29 @@ We have support to Google Cloud Schedule. It's based on Cloud tasks, the jobs ar
105
105
  Check out the follow sample of config file:
106
106
  ```yaml
107
107
  # config/scheduler.yml
108
- - name: Users::SyncJob
108
+ - name: UsersSyncJob
109
109
  schedule: 0 8 * * *
110
110
  description: Sync user data
111
111
  time_zone: "America/Los_Angeles"
112
+ class_name: Users::SyncJob
112
113
  args:
113
- arg1: 100
114
- arg2: 200
114
+ - this_first: argument
115
+ is_a: hash
116
+ - - this second argument
117
+ - is an array
118
+ - this third argument is a string
115
119
  ```
116
120
 
117
- | attribute | description | required |
118
- |------------- |---------------------------------------------------------------- |---------- |
119
- | name | The Job class namespace | ✓ |
120
- | schedule | The frequency to run your job. It should be a unix-cron format | ✓ |
121
- | description | What this job does | ✓ |
122
- | time_zone | Choose which one timezone your job must run | ✓ |
123
- | args | What are the job's arguments | |
121
+ | attribute | description | required |
122
+ |------------- |---------------------------------------------------------------------------------- |---------- |
123
+ | name | Any descriptive name, following [Tasks naming restrictions][1] | ✓ |
124
+ | schedule | The frequency to run your job. It should be a unix-cron format | ✓ |
125
+ | description | What this job does | ✓ |
126
+ | time_zone | Choose which one timezone your job must run | ✓ |
127
+ | args | Arguments to the job execution. Important: if present, this must be an array of items. Check out the example above | 𐄂 |
128
+ | class_name | The Job class name (including namespace) | ✓ |
124
129
 
130
+ [1]: https://cloud.google.com/tasks/docs/reference/rpc/google.cloud.tasks.v2
125
131
 
126
132
 
127
133
 
@@ -49,7 +49,7 @@ module RailsCloudTasks
49
49
 
50
50
  def self.queue_adapter
51
51
  @queue_adapter ||= Adapter.new
52
- rescue StandardError => e
52
+ rescue Errno::EHOSTDOWN => e
53
53
  raise e unless Rails.env.development?
54
54
 
55
55
  logger.warn('unable to setup adapter, falling back to :inline')
@@ -15,11 +15,7 @@ module RailsCloudTasks
15
15
  request = ::Rack::Request.new(env)
16
16
  job_args = extract_args(request)
17
17
 
18
- if job_args
19
- job_class.perform_now(job_args)
20
- else
21
- job_class.perform_now
22
- end
18
+ job_class.perform_now(*job_args)
23
19
 
24
20
  response(200, {})
25
21
  rescue Rack::InvalidPayloadError => e
@@ -37,7 +33,7 @@ module RailsCloudTasks
37
33
 
38
34
  def extract_args(request)
39
35
  body = request.body.read
40
- JSON.parse(body)
36
+ JSON.parse(body) || []
41
37
  rescue JSON::ParserError, KeyError
42
38
  raise Rack::InvalidPayloadError
43
39
  end
@@ -45,7 +45,7 @@ module RailsCloudTasks
45
45
  description: job[:description],
46
46
  time_zone: job[:time_zone],
47
47
  http_target: {
48
- uri: "#{host}#{tasks_path}/#{job[:class_name] || job[:name]}",
48
+ uri: "#{host}#{tasks_path}/#{job[:class_name]}",
49
49
  http_method: 'POST',
50
50
  body: job[:args].to_json
51
51
  }.merge(auth)
@@ -1,3 +1,3 @@
1
1
  module RailsCloudTasks
2
- VERSION = '0.0.4rc2'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-cloud-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4rc2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Araújo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -312,9 +312,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
312
  version: '2.4'
313
313
  required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  requirements:
315
- - - ">"
315
+ - - ">="
316
316
  - !ruby/object:Gem::Version
317
- version: 1.3.1
317
+ version: '0'
318
318
  requirements: []
319
319
  rubygems_version: 3.1.4
320
320
  signing_key: