activejob-google_cloud_tasks-http 0.1.3 → 0.2.0

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: 06b5da976d41cd61619702524da58f0dea6226b3f6b5510455d5556afb5a5910
4
- data.tar.gz: 567bdda0e0b4e4f6e279c3bfce9508ba795035366c279d9e45cde6b9d638e47d
3
+ metadata.gz: 1f75ab5b15c876b764b2a30837307a55179e4b158845237b1c46867331728f0e
4
+ data.tar.gz: 8c367bb1dc438647af0a164fdbe9bc7fb89055e83ce4b1a26d845f1fce9ab0a7
5
5
  SHA512:
6
- metadata.gz: b9c65beebd8426e212fae8b5266f5ae911c1ff28f343be83d4e8003af23e7690a0a7c20c4c1cf16ebfbdee52c88436dacee3fb4db00d17a45e1de50549757b6a
7
- data.tar.gz: ea19d25710b97c8b38afbb258da990e338457f38c88da277ef3dd1bcf41ff1931eca60d158c90378d2ac2178a9886af11e95dcbb8e4f4268754a8034f7dfd797
6
+ metadata.gz: e75a8f803782889055e447ccb0dd13dd57978a63d7adeb33a5f59da8052965db1621bb3aa432087c6d36196170be3f323068fac3a173893bb9756c05798ef8ec
7
+ data.tar.gz: 23ad68ee012868e82b8baf6ae0a28fc63c8a36e061cb0fe24308a6e544fe9ab0d04e04a170e22da555720b213bedc4a2713f22128cdd6de17c38cdbdb1de8c27
@@ -0,0 +1,18 @@
1
+ name: Verify
2
+ on:
3
+ - push
4
+
5
+ jobs:
6
+ tests:
7
+ name: Tests
8
+ runs-on: ubuntu-latest
9
+ container:
10
+ image: ruby
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v2
14
+
15
+ - name: Install dependencies and run tests
16
+ run: |
17
+ bundle
18
+ rake spec
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,23 @@
1
+ ## 0.2.0
2
+
3
+ This version depends on google-cloud-tasks 2.0 or later. Since google-cloud-tasks 2.0 has API changes, upgrading to this version may affect to existing adapter initialization code. If you are initializing Google::Cloud::Tasks client manually, you will have to change `Google::Cloud::Tasks.new` to `Google::Cloud::Tasks.cloud_tasks` as follows:
4
+
5
+ from:
6
+
7
+ Rails.application.config.active_job.queue_adapter = ActiveJob::GoogleCloudTasks::HTTP::Adapter.new(
8
+ client: Google::Cloud::Tasks.new(version: :v2beta3),
9
+ # ...
10
+ )
11
+
12
+ to:
13
+
14
+ Rails.application.config.active_job.queue_adapter = ActiveJob::GoogleCloudTasks::HTTP::Adapter.new(
15
+ client: Google::Cloud::Tasks.cloud_tasks(version: :v2beta3),
16
+ # ...
17
+ )
18
+
19
+ For more information, see this migration guide: https://github.com/googleapis/google-cloud-ruby/blob/master/google-cloud-tasks/MIGRATING.md
20
+
21
+ ## 0.1.0
22
+
23
+ :tada:
data/README.md CHANGED
@@ -29,7 +29,7 @@ Rails.application.config.active_job.queue_adapter = ActiveJob::GoogleCloudTasks:
29
29
  project: 'a-gcp-project-name',
30
30
  location: 'asia-northeast1',
31
31
  url: 'https://an-endpoint-to-perform-jobs.a.run.app/_jobs',
32
- client: Google::Cloud::Tasks.new(version: :v2beta3), # optional
32
+ client: Google::Cloud::Tasks.cloud_tasks(version: :v2beta3), # optional
33
33
  task_options: { # optional
34
34
  oidc_token: {
35
35
  service_account_email: 'cloudrun-invoker@a-gcp-project-name.iam.gserviceaccount.com'
@@ -65,6 +65,24 @@ Requiring `active_job/google_cloud_tasks/http/inline` makes the adapter skip enq
65
65
  require 'active_job/google_cloud_tasks/http/inline' unless Rails.env.production?
66
66
  ```
67
67
 
68
+ #### Error when calling assets:precompile?
69
+
70
+ When you call assets:precompile, all configs and initializers are loaded. If you load your credentials via environment variables they may not be available and the adapter initialization will cause errors. To solve this, wrap the `queue_adapter` config in a `unless ARGV.include?("assets:precompile")` condition. e.g.:
71
+
72
+ ```ruby
73
+ unless ARGV.include?("assets:precompile") # prevents running on assets:precompile
74
+ Rails.application.config.active_job.queue_adapter = ActiveJob::GoogleCloudTasks::HTTP::Adapter.new(
75
+ project: 'my-project',
76
+ location: 'europe-west2',
77
+ url: 'https://www.example.com/jobs',
78
+ client: Google::Cloud::Tasks.cloud_tasks(
79
+ version: :v2beta3,
80
+ credentials: JSON.parse(ENV["GOOGLE_CLOUD_PRODUCTION_KEYFILE"]) # this will cause an error if the environment variable does not exist
81
+ )
82
+ )
83
+ end
84
+ ```
85
+
68
86
  ## Development
69
87
 
70
88
  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.
@@ -17,16 +17,16 @@ Gem::Specification.new do |spec|
17
17
  # Specify which files should be added to the gem when it is released.
18
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
19
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|example-app)/}) }
21
21
  end
22
22
  spec.bindir = "exe"
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_runtime_dependency "activejob"
27
- spec.add_runtime_dependency "google-cloud-tasks"
27
+ spec.add_runtime_dependency "google-cloud-tasks", ">= 2.0.0"
28
28
  spec.add_runtime_dependency "rack"
29
- spec.add_development_dependency "bundler", "~> 1.17"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "bundler"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "rspec"
32
32
  end
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
2
  require 'google/cloud/tasks'
3
+ require 'gapic/grpc' # to use Google::Protobuf::Timestamp which is used by Google::Cloud::Tasks::Vxx
3
4
 
4
5
  module ActiveJob
5
6
  module GoogleCloudTasks
@@ -14,10 +15,10 @@ module ActiveJob
14
15
  end
15
16
 
16
17
  def enqueue(job, attributes = {})
17
- path = client.queue_path(@project, @location, job.queue_name)
18
+ path = client.queue_path(project: @project, location: @location, queue: job.queue_name)
18
19
  task = build_task(job, attributes)
19
20
 
20
- client.create_task path, task
21
+ client.create_task parent: path, task: task
21
22
  end
22
23
 
23
24
  def enqueue_at(job, scheduled_at)
@@ -27,7 +28,7 @@ module ActiveJob
27
28
  private
28
29
 
29
30
  def client
30
- @client ||= Google::Cloud::Tasks.new(version: :v2beta3)
31
+ @client ||= Google::Cloud::Tasks.cloud_tasks(version: :v2beta3)
31
32
  end
32
33
 
33
34
  def build_task(job, attributes)
@@ -1,7 +1,7 @@
1
1
  module ActiveJob
2
2
  module GoogleCloudTasks
3
3
  module HTTP
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob-google_cloud_tasks-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hibariya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-04 00:00:00.000000000 Z
11
+ date: 2020-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,44 +56,44 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.17'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.17'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '3.0'
96
+ version: '0'
97
97
  description: ActiveJob adapter for Google Cloud Tasks HTTP targets.
98
98
  email:
99
99
  - hibariya@gmail.com
@@ -101,8 +101,11 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/workflows/verify.yml"
104
105
  - ".gitignore"
106
+ - ".rspec"
105
107
  - ".travis.yml"
108
+ - CHANGELOG.md
106
109
  - CODE_OF_CONDUCT.md
107
110
  - Gemfile
108
111
  - LICENSE.txt
@@ -136,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
139
  - !ruby/object:Gem::Version
137
140
  version: '0'
138
141
  requirements: []
139
- rubygems_version: 3.0.3
142
+ rubygems_version: 3.1.2
140
143
  signing_key:
141
144
  specification_version: 4
142
145
  summary: ActiveJob adapter for Google Cloud Tasks HTTP targets.