activejob-google_cloud_tasks 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +9 -3
- data/Gemfile.lock +2 -2
- data/README.md +72 -13
- data/activejob-google_cloud_tasks.gemspec +1 -1
- data/credentials.tar.gz.enc +0 -0
- data/lib/activejob/google_cloud_tasks/adapter.rb +2 -2
- data/lib/activejob/google_cloud_tasks/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cef40a41790c74095ed991cd458ed8763162a88d
|
4
|
+
data.tar.gz: f475614b69bcb9399a6c2aa599efacc3676cf706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aad201da402e146372e57efda259511ea85385ec373a1f4af9251de6d171f89e8066675a4afbdfced02cd4d7d36a682024f562336b99959e2d3325e359a5b4d
|
7
|
+
data.tar.gz: 5720b7da001b0e62fc1a87c4b4939599085f02b824a640e85b1181fc716f338bd15864526602165d42cb63276fc7ffcf6da5cac1276a37d3665cdf0cdd18192f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
---
|
2
1
|
sudo: false
|
3
2
|
language: ruby
|
4
3
|
cache: bundler
|
5
4
|
rvm:
|
6
|
-
|
7
|
-
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
|
+
before_install:
|
8
|
+
- openssl aes-256-cbc -K $encrypted_63c75f50f8e0_key -iv $encrypted_63c75f50f8e0_iv -in credentials.tar.gz.enc -out credentials.tar.gz -d
|
9
|
+
- tar -xzf credentials.tar.gz
|
10
|
+
- export GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/client-secret.json
|
11
|
+
- gem install bundler -v 1.17.1
|
12
|
+
script:
|
13
|
+
- bundle exec rake spec
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,38 +1,97 @@
|
|
1
1
|
# Activejob::GoogleCloudTasks
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/kawabatas/activejob-google_cloud_tasks.svg?branch=master)](https://travis-ci.org/kawabatas/activejob-google_cloud_tasks)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/activejob-google_cloud_tasks.svg)](https://badge.fury.io/rb/activejob-google_cloud_tasks)
|
4
5
|
|
5
|
-
|
6
|
+
Google Cloud Tasks adapter for ActiveJob
|
7
|
+
|
8
|
+
## Prerequisites
|
9
|
+
- [Creating App Engine Queues](https://cloud.google.com/tasks/docs/creating-appengine-queues)
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
Add this line to your application's Gemfile:
|
10
14
|
|
11
15
|
```ruby
|
12
|
-
gem 'activejob-google_cloud_tasks'
|
16
|
+
gem 'activejob-google_cloud_tasks', '>= 0.1.2'
|
13
17
|
```
|
14
18
|
|
15
|
-
|
19
|
+
## Usage
|
16
20
|
|
17
|
-
|
21
|
+
First, change the ActiveJob backend.
|
18
22
|
|
19
|
-
|
23
|
+
``` ruby
|
24
|
+
Rails.application.config.active_job.queue_adapter = Activejob::GoogleCloudTasks::Adapter.new(
|
25
|
+
project: 'MY_GOOGLE_CLOUD_TASKS_PROJECT',
|
26
|
+
location: 'MY_GOOGLE_CLOUD_TASKS_LOCATION'
|
27
|
+
)
|
28
|
+
```
|
20
29
|
|
21
|
-
|
30
|
+
Second, mount the rack application.
|
22
31
|
|
23
|
-
|
32
|
+
``` ruby
|
33
|
+
Rails.application.routes.draw do
|
34
|
+
mount Activejob::GoogleCloudTasks::Rack, at: Activejob::GoogleCloudTasks::Config.path
|
35
|
+
end
|
36
|
+
```
|
24
37
|
|
25
|
-
|
38
|
+
Write the Job class and code to use it.
|
26
39
|
|
27
|
-
|
40
|
+
Note: perform argument is one and it must be hash.
|
28
41
|
|
29
|
-
|
42
|
+
``` ruby
|
43
|
+
class SampleJob < ApplicationJob
|
44
|
+
queue_as :default
|
45
|
+
def perform(args)
|
46
|
+
puts "hello, #{args[:name]}!"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
``` ruby
|
52
|
+
class SampleController < ApplicationController
|
53
|
+
def job
|
54
|
+
SampleJob.perform_later({name: 'ken'})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
### Adapter
|
60
|
+
``` ruby
|
61
|
+
Rails.application.config.active_job.queue_adapter = Activejob::GoogleCloudTasks::Adapter.new(
|
62
|
+
project: 'MY_GOOGLE_CLOUD_TASKS_PROJECT',
|
63
|
+
location: 'MY_GOOGLE_CLOUD_TASKS_LOCATION',
|
64
|
+
|
65
|
+
cloud_tasks_client: Google::Cloud::Tasks.new(
|
66
|
+
version: :v2beta3,
|
67
|
+
credentials: 'path/to/keyfile.json'
|
68
|
+
)
|
69
|
+
)
|
70
|
+
```
|
30
71
|
|
31
|
-
|
72
|
+
#### Argument Reference
|
73
|
+
- `project` - (Required) The ID of the Google Cloud project in which the Cloud Tasks belongs.
|
74
|
+
|
75
|
+
- `location` - (Required) The Location of the Cloud Tasks.
|
76
|
+
|
77
|
+
- `cloud_tasks_client` - (Optional) The instance of `Google::Cloud::Tasks`. Please see [`Google::Cloud::Tasks.new`](https://googleapis.github.io/google-cloud-ruby/docs/google-cloud-tasks/latest/Google/Cloud/Tasks.html#new-class_method) for details. Default: `Google::Cloud::Tasks.new(version: :v2beta3)`
|
78
|
+
|
79
|
+
### Config
|
80
|
+
```
|
81
|
+
Activejob::GoogleCloudTasks::Config.path = '/foo'
|
82
|
+
```
|
83
|
+
|
84
|
+
- `path` - (Optional) The path which the Cloud Tasks service forwards the task request to the worker. Default: `/activejobs`
|
85
|
+
|
86
|
+
## Development
|
87
|
+
|
88
|
+
``` sh
|
89
|
+
$ bundle exec rake spec
|
90
|
+
```
|
32
91
|
|
33
92
|
## Contributing
|
34
93
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kawabatas/activejob-google_cloud_tasks.
|
36
95
|
|
37
96
|
## License
|
38
97
|
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_runtime_dependency 'rack'
|
25
|
+
spec.add_runtime_dependency 'rack', ">= 2.0.6"
|
26
26
|
spec.add_runtime_dependency 'activejob'
|
27
27
|
spec.add_runtime_dependency 'activesupport'
|
28
28
|
spec.add_runtime_dependency 'google-cloud-tasks', '~> 0.2.6'
|
Binary file
|
@@ -5,10 +5,10 @@ require 'google/cloud/tasks/v2beta3/cloud_tasks_client'
|
|
5
5
|
module Activejob
|
6
6
|
module GoogleCloudTasks
|
7
7
|
class Adapter
|
8
|
-
def initialize(project:, location:)
|
8
|
+
def initialize(project:, location:, cloud_tasks_client: Google::Cloud::Tasks.new(version: :v2beta3))
|
9
9
|
@project = project
|
10
10
|
@location = location
|
11
|
-
@cloud_tasks_client =
|
11
|
+
@cloud_tasks_client = cloud_tasks_client
|
12
12
|
end
|
13
13
|
|
14
14
|
def enqueue(job, attributes = {})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-google_cloud_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kawabata Shintaro
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activejob
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- activejob-google_cloud_tasks.gemspec
|
141
141
|
- bin/console
|
142
142
|
- bin/setup
|
143
|
+
- credentials.tar.gz.enc
|
143
144
|
- lib/activejob/google_cloud_tasks.rb
|
144
145
|
- lib/activejob/google_cloud_tasks/adapter.rb
|
145
146
|
- lib/activejob/google_cloud_tasks/config.rb
|