rails-cloud-tasks 0.0.4 → 0.0.8

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: 4ab8eda2821b2bba5e155d3444c4cdf5fca633dd468753f4d177354e6ec1207b
4
- data.tar.gz: 71a5080bcc0693ea95b68b416246da57e671d7fb24d3bc46a95a895e96c521a5
3
+ metadata.gz: a0a927e98f448694a013a81f2c49b7c29d98ae25a6e5dc7fab721d2cd9da6412
4
+ data.tar.gz: e7121d86e71dbf30c69b22eb751a34bc8242308a81e1815e5529bf89f611d640
5
5
  SHA512:
6
- metadata.gz: f4ed01e0744ec482ad3d3015f92b35eee118601b1d95b7e7d5e3d030a1ff5f243224f35c527574aa8f3a6e8470fab3f2981fd39607e3f4456601501dfeb636b3
7
- data.tar.gz: 33b16e211328e0123c85381640087b2d4e1cfca7c0a0fdab0e7777cd20fb3dc148892762eebbf4ec269751b2bf0edb6c1b1f7f2e978962e8ba0d92012e05205c
6
+ metadata.gz: 953fe7f7bedb2174b5030e4d71f85bd393f5c57526efd01086bb3175485a9fc3d7e9a28f588073cde7d1799285c6508151a7f483b4380c366719119b536f4711
7
+ data.tar.gz: b6347af198ff733ed55bd3f281ce45094ffe298b0bce26711b6f54aa2668bff2cba47a5846761593f72f6ec034a7a99153f7c9dcf067471c8a2238ca2b61a7e3
@@ -23,7 +23,7 @@ jobs:
23
23
  run: gem install bundler
24
24
 
25
25
  - name: Cache dependencies
26
- uses: actions/cache@v1
26
+ uses: actions/cache@v2
27
27
  with:
28
28
  path: vendor/bundle
29
29
  key: ${{ runner.os }}-gem-${{ hashFiles('**/rails-cloud-tasks.gemspec') }}
@@ -48,7 +48,7 @@ jobs:
48
48
  run: gem install bundler
49
49
 
50
50
  - name: Cache dependencies
51
- uses: actions/cache@v1
51
+ uses: actions/cache@v2
52
52
  with:
53
53
  path: vendor/bundle
54
54
  key: ${{ runner.os }}-gem-${{ hashFiles('**/rails-cloud-tasks.gemspec') }}
@@ -73,7 +73,7 @@ jobs:
73
73
  run: gem install bundler
74
74
 
75
75
  - name: Cache dependencies
76
- uses: actions/cache@v1
76
+ uses: actions/cache@v2
77
77
  with:
78
78
  path: vendor/bundle
79
79
  key: ${{ runner.os }}-gem-${{ hashFiles('**/rails-cloud-tasks.gemspec') }}
@@ -25,7 +25,7 @@ jobs:
25
25
  run: gem install bundler
26
26
 
27
27
  - name: Cache dependencies
28
- uses: actions/cache@v1
28
+ uses: actions/cache@v2
29
29
  with:
30
30
  path: vendor/bundle
31
31
  key: ${{ runner.os }}-gem-${{ hashFiles('**/rails-cloud-tasks.gemspec') }}-2.7
@@ -67,7 +67,7 @@ jobs:
67
67
  run: gem install bundler
68
68
 
69
69
  - name: Cache dependencies
70
- uses: actions/cache@v1
70
+ uses: actions/cache@v2
71
71
  with:
72
72
  path: vendor/bundle
73
73
  key: ${{ runner.os }}-gem-${{ hashFiles('**/rails-cloud-tasks.gemspec') }}-2.7
@@ -49,7 +49,7 @@ module RailsCloudTasks
49
49
 
50
50
  def self.queue_adapter
51
51
  @queue_adapter ||= Adapter.new
52
- rescue Errno::EHOSTDOWN => e
52
+ rescue StandardError => e
53
53
  raise e unless Rails.env.development?
54
54
 
55
55
  logger.warn('unable to setup adapter, falling back to :inline')
@@ -2,14 +2,8 @@ require 'google-cloud-tasks'
2
2
 
3
3
  module RailsCloudTasks
4
4
  class Adapter
5
- attr_reader :client
6
-
7
5
  delegate :project_id, :location_id, :host, :tasks_path, :auth, to: 'RailsCloudTasks.config'
8
6
 
9
- def initialize(client = Google::Cloud::Tasks.cloud_tasks)
10
- @client = client
11
- end
12
-
13
7
  def enqueue(job, timestamp = nil)
14
8
  path = client.queue_path(project: project_id, location: location_id, queue: job.queue_name)
15
9
  task = build_task(job, timestamp)
@@ -28,6 +22,10 @@ module RailsCloudTasks
28
22
  enqueue(job, timestamp.to_i)
29
23
  end
30
24
 
25
+ def client
26
+ @client ||= Google::Cloud::Tasks.cloud_tasks
27
+ end
28
+
31
29
  private
32
30
 
33
31
  def url
@@ -1,7 +1,6 @@
1
1
  module RailsCloudTasks
2
2
  class Credentials
3
3
  require 'googleauth'
4
- require 'google/apis/cloudscheduler_v1'
5
4
  require 'google/apis/iamcredentials_v1'
6
5
 
7
6
  DEFAULT_SCOPES = ['https://www.googleapis.com/auth/cloud-platform'].freeze
@@ -20,8 +20,6 @@ module RailsCloudTasks
20
20
  response(200, {})
21
21
  rescue Rack::InvalidPayloadError => e
22
22
  response(422, { error: e.message })
23
- rescue StandardError => e
24
- response(500, { error: e.message })
25
23
  end
26
24
 
27
25
  private
@@ -17,8 +17,6 @@ module RailsCloudTasks
17
17
  response(200, {})
18
18
  rescue Rack::InvalidPayloadError => e
19
19
  response(400, { error: e.cause.message })
20
- rescue StandardError => e
21
- response(500, { error: e.message })
22
20
  end
23
21
 
24
22
  private
@@ -4,17 +4,13 @@ module RailsCloudTasks
4
4
  :scheduler_file_path, :scheduler_prefix_name,
5
5
  :service_account_email, to: 'RailsCloudTasks.config'
6
6
 
7
- attr_reader :client, :credentials, :logger
7
+ attr_reader :credentials, :logger
8
8
 
9
9
  def initialize(
10
- client: Google::Cloud::Scheduler.cloud_scheduler,
11
10
  credentials: RailsCloudTasks::Credentials.new,
12
11
  logger: RailsCloudTasks.logger
13
12
  )
14
- client.configure do |config|
15
- config.credentials = credentials.generate(service_account_email)
16
- end
17
- @client = client
13
+ @credentials = credentials
18
14
  @logger = logger
19
15
  end
20
16
 
@@ -28,6 +24,13 @@ module RailsCloudTasks
28
24
  log_output(result)
29
25
  end
30
26
 
27
+ def client
28
+ configure = lambda { |client|
29
+ client.configure.credentials = credentials.generate(service_account_email)
30
+ }
31
+ @client ||= Google::Cloud::Scheduler.cloud_scheduler.tap(&configure)
32
+ end
33
+
31
34
  protected
32
35
 
33
36
  def location_path
@@ -1,3 +1,3 @@
1
1
  module RailsCloudTasks
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.8'.freeze
3
3
  end
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
23
23
  end
24
24
 
25
25
  spec.add_dependency 'activesupport', '>= 4'
26
- spec.add_dependency 'google-apis-cloudscheduler_v1'
27
26
  spec.add_dependency 'google-apis-iamcredentials_v1'
28
27
  spec.add_dependency 'google-cloud-scheduler', '>= 2'
29
28
  spec.add_dependency 'google-cloud-tasks', '>= 2'
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.4
4
+ version: 0.0.8
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-17 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4'
27
- - !ruby/object:Gem::Dependency
28
- name: google-apis-cloudscheduler_v1
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
27
  - !ruby/object:Gem::Dependency
42
28
  name: google-apis-iamcredentials_v1
43
29
  requirement: !ruby/object:Gem::Requirement