activejob-google_cloud_tasks 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f616c2d1d60a6c8426d1b7411f559afe0c490b40
4
+ data.tar.gz: 2d765900fa68837094bec1d9e8189838a5d95783
5
+ SHA512:
6
+ metadata.gz: 74cb21526b5f91232f2a1253f19f7d8ab710a50cb5a2cdea9715c06c667b7ddd5db0d612fd2e6cf7c9cd0690f7acf674ad22e2f447cd3955eee863fccfb9418a
7
+ data.tar.gz: 6cf5dbce0448b5dfd1204b45f292a81da8586e94fb4ff5c90a13bb942bcbefab5394e082303a44316f6ffcf7bb75b81e424ed5ccbab50d052cc12b76d51d8d23
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.1
7
+ before_install: gem install bundler -v 1.17.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in activejob-google_cloud_tasks.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,105 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activejob-google_cloud_tasks (0.1.0)
5
+ activejob
6
+ activesupport
7
+ google-cloud-tasks (~> 0.2.6)
8
+ rack
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activejob (5.2.1)
14
+ activesupport (= 5.2.1)
15
+ globalid (>= 0.3.6)
16
+ activesupport (5.2.1)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ addressable (2.5.2)
22
+ public_suffix (>= 2.0.2, < 4.0)
23
+ concurrent-ruby (1.1.3)
24
+ diff-lcs (1.3)
25
+ faraday (0.15.3)
26
+ multipart-post (>= 1.2, < 3)
27
+ globalid (0.4.1)
28
+ activesupport (>= 4.2.0)
29
+ google-cloud-tasks (0.2.6)
30
+ google-gax (~> 1.3)
31
+ grpc-google-iam-v1 (~> 0.6.9)
32
+ google-gax (1.4.0)
33
+ google-protobuf (~> 3.2)
34
+ googleapis-common-protos (>= 1.3.5, < 2.0)
35
+ googleauth (~> 0.6.2)
36
+ grpc (>= 1.7.2, < 2.0)
37
+ rly (~> 0.2.3)
38
+ google-protobuf (3.6.1)
39
+ googleapis-common-protos (1.3.7)
40
+ google-protobuf (~> 3.0)
41
+ googleapis-common-protos-types (~> 1.0)
42
+ grpc (~> 1.0)
43
+ googleapis-common-protos-types (1.0.2)
44
+ google-protobuf (~> 3.0)
45
+ googleauth (0.6.7)
46
+ faraday (~> 0.12)
47
+ jwt (>= 1.4, < 3.0)
48
+ memoist (~> 0.16)
49
+ multi_json (~> 1.11)
50
+ os (>= 0.9, < 2.0)
51
+ signet (~> 0.7)
52
+ grpc (1.16.0)
53
+ google-protobuf (~> 3.1)
54
+ googleapis-common-protos-types (~> 1.0.0)
55
+ grpc-google-iam-v1 (0.6.9)
56
+ googleapis-common-protos (>= 1.3.1, < 2.0)
57
+ grpc (~> 1.0)
58
+ i18n (1.1.1)
59
+ concurrent-ruby (~> 1.0)
60
+ jwt (2.1.0)
61
+ memoist (0.16.0)
62
+ minitest (5.11.3)
63
+ multi_json (1.13.1)
64
+ multipart-post (2.0.0)
65
+ os (1.0.0)
66
+ public_suffix (3.0.3)
67
+ rack (2.0.6)
68
+ rack-test (1.1.0)
69
+ rack (>= 1.0, < 3)
70
+ rake (10.5.0)
71
+ rly (0.2.3)
72
+ rspec (3.8.0)
73
+ rspec-core (~> 3.8.0)
74
+ rspec-expectations (~> 3.8.0)
75
+ rspec-mocks (~> 3.8.0)
76
+ rspec-core (3.8.0)
77
+ rspec-support (~> 3.8.0)
78
+ rspec-expectations (3.8.2)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.8.0)
81
+ rspec-mocks (3.8.0)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.8.0)
84
+ rspec-support (3.8.0)
85
+ signet (0.11.0)
86
+ addressable (~> 2.3)
87
+ faraday (~> 0.9)
88
+ jwt (>= 1.5, < 3.0)
89
+ multi_json (~> 1.10)
90
+ thread_safe (0.3.6)
91
+ tzinfo (1.2.5)
92
+ thread_safe (~> 0.1)
93
+
94
+ PLATFORMS
95
+ ruby
96
+
97
+ DEPENDENCIES
98
+ activejob-google_cloud_tasks!
99
+ bundler (~> 1.17)
100
+ rack-test
101
+ rake (~> 10.0)
102
+ rspec (~> 3.0)
103
+
104
+ BUNDLED WITH
105
+ 1.17.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 kawabata_shintaro
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.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Activejob::GoogleCloudTasks
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.
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 'activejob-google_cloud_tasks'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install activejob-google_cloud_tasks
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/[USERNAME]/activejob-google_cloud_tasks.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "activejob/google_cloud_tasks/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activejob-google_cloud_tasks"
8
+ spec.version = Activejob::GoogleCloudTasks::VERSION
9
+ spec.authors = ["Kawabata Shintaro"]
10
+ spec.email = [""]
11
+
12
+ spec.summary = "Google Cloud Tasks adapter for ActiveJob"
13
+ spec.homepage = "https://github.com/kawabatas/activejob-google_cloud_tasks"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_runtime_dependency 'rack'
26
+ spec.add_runtime_dependency 'activejob'
27
+ spec.add_runtime_dependency 'activesupport'
28
+ spec.add_runtime_dependency 'google-cloud-tasks', '~> 0.2.6'
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.17"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "rack-test"
34
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "activejob/google_cloud_tasks"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ module Activejob
2
+ module GoogleCloudTasks
3
+ autoload :Adapter, 'activejob/google_cloud_tasks/adapter'
4
+ autoload :Config, 'activejob/google_cloud_tasks/config'
5
+ autoload :Rack, 'activejob/google_cloud_tasks/rack'
6
+ autoload :VERSION, 'activejob/google_cloud_tasks/version'
7
+ end
8
+ end
@@ -0,0 +1,32 @@
1
+ require 'activejob/google_cloud_tasks/config'
2
+ require 'google/cloud/tasks/v2beta3'
3
+
4
+ module Activejob
5
+ module GoogleCloudTasks
6
+ class Adapter
7
+ def initialize(project:, location:)
8
+ @project = project
9
+ @location = location
10
+ @cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
11
+ end
12
+
13
+ def enqueue(job, attributes = {})
14
+ formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path(@project, @location, job.queue_name)
15
+ relative_uri = "#{Activejob::GoogleCloudTasks::Config.path}/perform?job=#{job.class.to_s}&#{job.arguments.to_param}"
16
+
17
+ task = {
18
+ app_engine_http_request: {
19
+ http_method: :GET,
20
+ relative_uri: relative_uri
21
+ }
22
+ }
23
+ task[:schedule_time] = Google::Protobuf::Timestamp.new(seconds: attributes[:scheduled_at].to_i) if attributes.has_key?(:scheduled_at)
24
+ @cloud_tasks_client.create_task(formatted_parent, task)
25
+ end
26
+
27
+ def enqueue_at(job, scheduled_at)
28
+ enqueue job, scheduled_at: scheduled_at
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ module Activejob
2
+ module GoogleCloudTasks
3
+ class Config
4
+ DEFAULT_PATH = '/activejobs'
5
+
6
+ def self.path
7
+ defined?(@path) ? @path : DEFAULT_PATH
8
+ end
9
+
10
+ def self.path=(path)
11
+ @path = path ? path : DEFAULT_PATH
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require 'rack'
2
+
3
+ module Activejob
4
+ module GoogleCloudTasks
5
+ class Rack
6
+ class << self
7
+ def call(env)
8
+ if env['PATH_INFO'].match(/^\/perform/)
9
+ params = Hash[URI::decode_www_form(env['QUERY_STRING'])].symbolize_keys
10
+ raise StandardError, "Job is not specified." unless params.has_key?(:job)
11
+
12
+ klass(params[:job]).perform_now(params)
13
+ [200, {}, ['ok']]
14
+ else
15
+ [404, {}, ['not found']]
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def klass(job)
22
+ Kernel.const_get(job.camelize)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ module Activejob
2
+ module GoogleCloudTasks
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activejob-google_cloud_tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kawabata Shintaro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activejob
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: google-cloud-tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.17'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.17'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rack-test
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - ''
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - activejob-google_cloud_tasks.gemspec
141
+ - bin/console
142
+ - bin/setup
143
+ - lib/activejob/google_cloud_tasks.rb
144
+ - lib/activejob/google_cloud_tasks/adapter.rb
145
+ - lib/activejob/google_cloud_tasks/config.rb
146
+ - lib/activejob/google_cloud_tasks/rack.rb
147
+ - lib/activejob/google_cloud_tasks/version.rb
148
+ homepage: https://github.com/kawabatas/activejob-google_cloud_tasks
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.6.11
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Google Cloud Tasks adapter for ActiveJob
172
+ test_files: []