activejob-google_cloud_tasks 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24b87f633a0a1136d387856e90c6e7869210058f
4
- data.tar.gz: f03242b34db220550e8805843a1210fc9935bf24
3
+ metadata.gz: cef40a41790c74095ed991cd458ed8763162a88d
4
+ data.tar.gz: f475614b69bcb9399a6c2aa599efacc3676cf706
5
5
  SHA512:
6
- metadata.gz: 854e667c2c581a28820a2e0df8658b9fc093163d49ac6a76343442178a1f5b177399cb07d37aa86b2cf69809cdbe127024523fa8f75c13aa75a0d07edf34dc09
7
- data.tar.gz: 447b61ebce8ceb3d62c22fdab23a939947740a44340181e57094dfe151e3a71ce7a37d1da0b5b839cb3e1105652272d5401d6d155e07008ffd276ddc298c710c
6
+ metadata.gz: 6aad201da402e146372e57efda259511ea85385ec373a1f4af9251de6d171f89e8066675a4afbdfced02cd4d7d36a682024f562336b99959e2d3325e359a5b4d
7
+ data.tar.gz: 5720b7da001b0e62fc1a87c4b4939599085f02b824a640e85b1181fc716f338bd15864526602165d42cb63276fc7ffcf6da5cac1276a37d3665cdf0cdd18192f
data/.gitignore CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ /credentials.tar.gz
14
+ /client-secret.json
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
- - 2.4.1
7
- before_install: gem install bundler -v 1.17.1
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
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activejob-google_cloud_tasks (0.1.1)
4
+ activejob-google_cloud_tasks (0.1.2)
5
5
  activejob
6
6
  activesupport
7
7
  google-cloud-tasks (~> 0.2.6)
8
- rack
8
+ rack (>= 2.0.6)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,38 +1,97 @@
1
1
  # Activejob::GoogleCloudTasks
2
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/activejob/google_cloud_tasks`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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
- And then execute:
19
+ ## Usage
16
20
 
17
- $ bundle
21
+ First, change the ActiveJob backend.
18
22
 
19
- Or install it yourself as:
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
- $ gem install activejob-google_cloud_tasks
30
+ Second, mount the rack application.
22
31
 
23
- ## Usage
32
+ ``` ruby
33
+ Rails.application.routes.draw do
34
+ mount Activejob::GoogleCloudTasks::Rack, at: Activejob::GoogleCloudTasks::Config.path
35
+ end
36
+ ```
24
37
 
25
- TODO: Write usage instructions here
38
+ Write the Job class and code to use it.
26
39
 
27
- ## Development
40
+ Note: perform argument is one and it must be hash.
28
41
 
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.
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
- 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).
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/[USERNAME]/activejob-google_cloud_tasks.
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 = Google::Cloud::Tasks.new(version: :v2beta3)
11
+ @cloud_tasks_client = cloud_tasks_client
12
12
  end
13
13
 
14
14
  def enqueue(job, attributes = {})
@@ -1,5 +1,5 @@
1
1
  module Activejob
2
2
  module GoogleCloudTasks
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
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.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: '0'
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: '0'
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