datahen 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/datahen/client/base.rb +5 -2
- data/lib/datahen/client/job.rb +2 -2
- data/lib/datahen/client/job_output.rb +1 -1
- data/lib/datahen/client/job_page.rb +1 -1
- data/lib/datahen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beadb0e5b371134e96d8e1888250de66411eb287a30cfc5f717e525c19343d6c
|
4
|
+
data.tar.gz: 298daaf6f56f1fcfb4e842b9e82d0e4f8896315d264b9481aa2ed4ec55bc8a9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cba2e599b72315d65cd20440c6a8804d7298bd577d5d24f9408bc71e35f47ee5abb8e7d580b7b42cc95c10608f852339a1d44ecfedaedd82acb565f5ffb05d2
|
7
|
+
data.tar.gz: 6a8c1c8f7d8deca7663699f7f20ea0e9cf7e7608b2d93150fb2fd4da438780fecff010332e43675800f94012739bfcda6a85dd27df1055958e6de0bbd4c158ab
|
data/lib/datahen/client/base.rb
CHANGED
@@ -13,6 +13,9 @@ module Datahen
|
|
13
13
|
finisher: nil
|
14
14
|
}
|
15
15
|
|
16
|
+
CHECK_NIL = lambda{|v|v.nil?}
|
17
|
+
CHECK_EMPTY_BODY = lambda{|v|v.body.nil? || v.body.empty?}
|
18
|
+
|
16
19
|
def self.env_auth_token
|
17
20
|
ENV['DATAHEN_TOKEN']
|
18
21
|
end
|
@@ -56,14 +59,14 @@ module Datahen
|
|
56
59
|
target.merge(source.select{|k,v|target.has_key?(k)})
|
57
60
|
end
|
58
61
|
|
59
|
-
def retry
|
62
|
+
def retry(times, delay = nil, err_msg = nil, stream = false, check_nil = CHECK_NIL)
|
60
63
|
limit = times.nil? ? nil : times.to_i
|
61
64
|
delay = delay.nil? ? 5 : delay.to_i
|
62
65
|
count = 0
|
63
66
|
begin
|
64
67
|
val = yield
|
65
68
|
if stream
|
66
|
-
return if val
|
69
|
+
return if check_nil.call(val)
|
67
70
|
if val['error'] != ""
|
68
71
|
raise StandardError.new(val['error'])
|
69
72
|
end
|
data/lib/datahen/client/job.rb
CHANGED
@@ -60,7 +60,7 @@ module Datahen
|
|
60
60
|
params = @options.merge({body: body.to_json})
|
61
61
|
|
62
62
|
limit = opts.has_key?(:retry_limit) ? opts.fetch(:retry_limit) : self.default_retry_limit[:seeder]
|
63
|
-
self.retry(limit, 5, "Error while updating the seeder.") do
|
63
|
+
self.retry(limit, 5, "Error while updating the seeder.", false, CHECK_EMPTY_BODY) do
|
64
64
|
response = self.class.put("/jobs/#{job_id}/seeding_update", params)
|
65
65
|
if response.code == 422 && response.body.to_s =~ /pq:\s*deadlock/i
|
66
66
|
raise CustomRetryError.new(self.class.random_delay(5), response.body.to_s)
|
@@ -78,7 +78,7 @@ module Datahen
|
|
78
78
|
params = @options.merge({body: body.to_json})
|
79
79
|
|
80
80
|
limit = opts.has_key?(:retry_limit) ? opts.fetch(:retry_limit) : self.default_retry_limit[:finisher]
|
81
|
-
self.retry(limit, 5, "Error while updating the finisher.") do
|
81
|
+
self.retry(limit, 5, "Error while updating the finisher.", false, CHECK_EMPTY_BODY) do
|
82
82
|
response = self.class.put("/jobs/#{job_id}/finisher_update", params)
|
83
83
|
if response.code == 422 && response.body.to_s =~ /pq:\s*deadlock/
|
84
84
|
raise CustomRetryError.new(self.class.random_delay(5), response.body.to_s)
|
@@ -7,7 +7,7 @@ module Datahen
|
|
7
7
|
|
8
8
|
def all(job_id, collection = 'default', opts = {})
|
9
9
|
limit = opts.has_key?(:retry_limit) ? opts.fetch(:retry_limit) : 0
|
10
|
-
self.retry(limit, 10, "Error while updating the seeder.", true) do
|
10
|
+
self.retry(limit, 10, "Error while updating the seeder.", true, CHECK_EMPTY_BODY) do
|
11
11
|
self.class.get("/jobs/#{job_id}/output/collections/#{collection}/records", @options)
|
12
12
|
end
|
13
13
|
end
|
@@ -63,7 +63,7 @@ module Datahen
|
|
63
63
|
params = @options.merge({body: body.to_json})
|
64
64
|
|
65
65
|
limit = opts.has_key?(:retry_limit) ? opts.fetch(:retry_limit) : self.default_retry_limit[:parser]
|
66
|
-
self.retry(limit, 5, "Error while updating the parser.") do
|
66
|
+
self.retry(limit, 5, "Error while updating the parser.", false, CHECK_EMPTY_BODY) do
|
67
67
|
response = self.class.put("/jobs/#{job_id}/pages/#{gid}/parsing_update", params)
|
68
68
|
if response.code == 422 && response.body.to_s =~ /pq:\s*deadlock/i
|
69
69
|
raise Error::CustomRetryError.new(self.class.random_delay(5), response.body.to_s)
|
data/lib/datahen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datahen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parama Danoesubroto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|