rails-cloud-tasks 0.0.5 → 0.0.9.pre.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_cloud_tasks/adapter.rb +6 -7
- data/lib/rails_cloud_tasks/credentials.rb +0 -1
- data/lib/rails_cloud_tasks/rack/jobs.rb +0 -2
- data/lib/rails_cloud_tasks/rack/tasks.rb +0 -2
- data/lib/rails_cloud_tasks/scheduler.rb +9 -6
- data/lib/rails_cloud_tasks/version.rb +1 -1
- data/rails-cloud-tasks.gemspec +0 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7799c658eb42896068a8b5e5627eba810e475b050938ac186094e0e3464cbcb6
|
4
|
+
data.tar.gz: 74a514db98b919e285ecafa9a3da8d96583e1cee412d07111d029c955ff81100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e269cec2ba7432ac8b6f63c94b9de6431dca995ea16dc0d5c62d084b7ec3f6f2d1858deaf25c7dc2c5bdaba1248fe369ffed25dbeb54dac1f030b83e4e5b19f
|
7
|
+
data.tar.gz: d27490520b8b77dfa8dacd61dc179d7900ccf17e89a858a35bb7faafb6d6e1927b0181f00b5c3ada8ebf1f61afe88a5f3e0829053c20d59d621e12688b2fe2ee
|
@@ -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
|
@@ -39,7 +37,8 @@ module RailsCloudTasks
|
|
39
37
|
http_request: {
|
40
38
|
http_method: :POST,
|
41
39
|
url: url,
|
42
|
-
body: { job: job.serialize }.to_json.force_encoding('ASCII-8BIT')
|
40
|
+
body: { job: job.serialize }.to_json.force_encoding('ASCII-8BIT'),
|
41
|
+
headers: { 'Content-Type': 'application/json' }
|
43
42
|
}.merge(auth),
|
44
43
|
schedule_time: timestamp && Google::Protobuf::Timestamp.new.tap do |ts|
|
45
44
|
ts.seconds = timestamp
|
@@ -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 :
|
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
|
-
|
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
|
data/rails-cloud-tasks.gemspec
CHANGED
@@ -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
|
+
version: 0.0.9.pre.rc
|
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-
|
11
|
+
date: 2021-04-07 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
|
@@ -312,9 +298,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
312
298
|
version: '2.4'
|
313
299
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
300
|
requirements:
|
315
|
-
- - "
|
301
|
+
- - ">"
|
316
302
|
- !ruby/object:Gem::Version
|
317
|
-
version:
|
303
|
+
version: 1.3.1
|
318
304
|
requirements: []
|
319
305
|
rubygems_version: 3.1.4
|
320
306
|
signing_key:
|