asyncapi-client 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/workers/asyncapi/client/cleaner_worker.rb +1 -3
- data/app/workers/asyncapi/client/job_cleaner_worker.rb +39 -5
- data/db/migrate/20141104030959_create_asyncapi_client_jobs.rb +1 -1
- data/db/migrate/20141119011011_add_callback_params_to_asyncapi_client_jobs.rb +1 -1
- data/db/migrate/20141212064041_add_secret_to_asyncapi_client_job.rb +1 -1
- data/db/migrate/20150202062211_add_expired_at_to_asyncapi_client_job.rb +1 -1
- data/db/migrate/20150202062320_populate_asyncapi_client_job_expired_at.rb +1 -1
- data/db/migrate/20150610053320_add_on_time_out_to_asyncapi_client_job.rb +1 -1
- data/db/migrate/20150612082965_add_time_out_index_to_asyncapi_client_job.rb +1 -1
- data/db/migrate/20150630004215_add_response_code_to_asyncapi_client_jobs.rb +1 -1
- data/db/migrate/20150703001225_add_on_queue_error_to_asyncapi_client_jobs.rb +1 -1
- data/db/migrate/20190218200630_add_expired_at_index_to_asyncapi_client_jobs.rb +11 -0
- data/lib/asyncapi/client/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb359e773a03ebfdcf520583dd45c19dd8fdbc53
|
4
|
+
data.tar.gz: aacd73eb3244465fa8d68b37ca784ff994e56fc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb344d71daa7c95cb318da4280b051a2f84c93caa2d17a1935df78b62e54f0e6625068cf8aa99eceacd898900151d152a118ad236f4df3cb77eef13f62669ad3
|
7
|
+
data.tar.gz: b7b6fea653dacf7bc0b936ad098a6e49ce98b30ffa6e7328e8ac78b7bc1684b9b025f8eb6ea2377695c60c2c4501ab706939faa9166e1f653e36c82a9eb3fd44
|
@@ -7,7 +7,7 @@ module Asyncapi
|
|
7
7
|
|
8
8
|
def perform(job_id)
|
9
9
|
if job = Job.find_by(id: job_id)
|
10
|
-
destroy_remote
|
10
|
+
destroy_remote(job)
|
11
11
|
job.destroy
|
12
12
|
end
|
13
13
|
end
|
@@ -15,12 +15,46 @@ module Asyncapi
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def destroy_remote(job)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
errors = validate_remote_job_info(job)
|
19
|
+
if errors.empty?
|
20
|
+
Typhoeus.delete(job.server_job_url, {
|
21
|
+
params: { secret: job.secret },
|
22
|
+
headers: job.headers,
|
23
|
+
})
|
24
|
+
else
|
25
|
+
log_remote_error_for(job, errors)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_remote_job_info(job)
|
30
|
+
errors = []
|
31
|
+
errors << "server_job_url is invalid" unless url_ok_for?(job)
|
32
|
+
errors << "authorization headers are not present" unless headers_ok_for?(job)
|
33
|
+
errors << "secret is not present" unless job.secret.present?
|
34
|
+
errors
|
35
|
+
end
|
36
|
+
|
37
|
+
def url_ok_for?(job)
|
38
|
+
uri = URI.parse(job.server_job_url)
|
39
|
+
uri.is_a?(URI::HTTP) && !uri.host.nil?
|
40
|
+
rescue URI::InvalidURIError
|
41
|
+
false
|
22
42
|
end
|
23
43
|
|
44
|
+
def headers_ok_for?(job)
|
45
|
+
job.headers.is_a?(Hash) && job.headers[:AUTHORIZATION]
|
46
|
+
end
|
47
|
+
|
48
|
+
def log_remote_error_for(job, errors)
|
49
|
+
if defined?(G5::Logger::Log)
|
50
|
+
G5::Logger::Log.send(:warn, {
|
51
|
+
origin: "#{self.class.name}#destroy_remote",
|
52
|
+
external_parent_id: "#{job.id}",
|
53
|
+
message: "Not enough info to delete expired remote job: #{errors.join(", ")}",
|
54
|
+
error: "Unable to delete remote job",
|
55
|
+
})
|
56
|
+
end
|
57
|
+
end
|
24
58
|
end
|
25
59
|
end
|
26
60
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class PopulateAsyncapiClientJobExpiredAt < ActiveRecord::Migration
|
1
|
+
class PopulateAsyncapiClientJobExpiredAt < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
Asyncapi::Client::Job.find_each do |job|
|
4
4
|
job.update_attributes(expired_at: Asyncapi::Client.expiry_threshold.from_now)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddExpiredAtIndexToAsyncapiClientJobs < ActiveRecord::Migration[5.0]
|
2
|
+
disable_ddl_transaction!
|
3
|
+
|
4
|
+
def change
|
5
|
+
opts = {}
|
6
|
+
if !!(ActiveRecord::Base.connection_config[:adapter] =~ /postgresql/i)
|
7
|
+
opts[:algorithm] = :concurrently
|
8
|
+
end
|
9
|
+
add_index :asyncapi_client_jobs, :expired_at, opts
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asyncapi-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- G5
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -128,16 +128,16 @@ dependencies:
|
|
128
128
|
name: sqlite3
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- - "
|
131
|
+
- - "~>"
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: 1.3.6
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- - "
|
138
|
+
- - "~>"
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
140
|
+
version: 1.3.6
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: rspec-rails
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- db/migrate/20150612082965_add_time_out_index_to_asyncapi_client_job.rb
|
268
268
|
- db/migrate/20150630004215_add_response_code_to_asyncapi_client_jobs.rb
|
269
269
|
- db/migrate/20150703001225_add_on_queue_error_to_asyncapi_client_jobs.rb
|
270
|
+
- db/migrate/20190218200630_add_expired_at_index_to_asyncapi_client_jobs.rb
|
270
271
|
- lib/asyncapi-client.rb
|
271
272
|
- lib/asyncapi/client.rb
|
272
273
|
- lib/asyncapi/client/engine.rb
|