elasticsearch_scanner 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elasticsearch_scanner.gemspec +1 -1
- data/lib/elasticsearch_scanner.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb608be40ca3681cdab9f457f157eef0c0a1e84271ced6a56246425f651a4b2
|
4
|
+
data.tar.gz: dd0390e0fbe9ca0a44f12c45140590be3204bc11bc31aceffc03529248fa0a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27259fcf1dd1871a13b54b93e4b4f2fbae6755f93569d5085bd1460b48f4e42711c290882c16ef9d9399e3cbf70ede8f61ae1b41833d104e69f9b6e96a72365d
|
7
|
+
data.tar.gz: de0c6f9087181f1337a28cbf58b06503ad1a3062737b91e602552e815cbc02ae591021f77ff191a02af6362fdb14548ec09a2b29a516cc98e741966d272b0d20
|
@@ -8,11 +8,12 @@ class ElasticSearchScanner
|
|
8
8
|
attr_reader :total_request_time,
|
9
9
|
:total_elasticsearch_time
|
10
10
|
|
11
|
-
def initialize(url, query, size=100, scroll_ttl='1m')
|
11
|
+
def initialize(url, query, size=100, scroll_ttl = '1m', max_retries = 5)
|
12
12
|
@url = url
|
13
13
|
@query = query
|
14
14
|
@size = size
|
15
15
|
@scroll_ttl = scroll_ttl
|
16
|
+
@max_retries = max_retries
|
16
17
|
@fields_to_return = true # all fields
|
17
18
|
@has_more = true
|
18
19
|
@total_request_time = 0.0
|
@@ -85,5 +86,13 @@ class ElasticSearchScanner
|
|
85
86
|
@scroll_id = data['_scroll_id']
|
86
87
|
@has_more = data['hits']['hits'].size == @size
|
87
88
|
data['hits']['hits']
|
89
|
+
rescue Net::ReadTimeout => e
|
90
|
+
attempts ||= 0
|
91
|
+
attempts += 1
|
92
|
+
if attempts < @max_retries
|
93
|
+
sleep([0.1, 0.2, 0.4, 1.0][attempts-1] || 1.0)
|
94
|
+
retry
|
95
|
+
end
|
96
|
+
raise e
|
88
97
|
end
|
89
98
|
end
|