zelastic 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +17 -6
- data/.rubocop.yml +4 -1
- data/.rubocop_todo.yml +32 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +15 -2
- data/lib/zelastic/index_manager.rb +3 -1
- data/lib/zelastic/indexer.rb +27 -5
- data/lib/zelastic/version.rb +1 -1
- data/zelastic.gemspec +1 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b9d19442778ad53fe696cbcf6d202b9216cd53
|
4
|
+
data.tar.gz: 3e8e17c98cc6ee0332449e232c7de492dc94f79e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7186c7a3dd66d97bc7567e33023742c2fda9718846d8e58c2bbe9c17ef18055858e7e5fb0b600d3629b365c300350e6b694068368a40599ccaf9be41c931d74
|
7
|
+
data.tar.gz: bd24900db1022ef69a0a457c03f50e3e2a1ec884e4eba60ddd2084a3555ba0e9921a99b39293dacc1436ebcf441de40eab8184f4269229c93127990dbe2a46e2
|
data/.circleci/config.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
references:
|
2
|
+
ruby: &ruby
|
3
|
+
image: carwow/ruby-ci:2.4.4
|
4
|
+
environment:
|
5
|
+
ELASTICSEARCH_URL: http://localhost:9200
|
3
6
|
|
4
|
-
elasticsearch_container: &elasticsearch_container
|
5
|
-
|
7
|
+
elasticsearch_container: &elasticsearch_container
|
8
|
+
image: carwow/elasticsearch-ci:5.5.1
|
6
9
|
|
7
10
|
version: 2
|
8
11
|
jobs:
|
@@ -30,7 +33,7 @@ jobs:
|
|
30
33
|
- *ruby
|
31
34
|
steps:
|
32
35
|
- checkout
|
33
|
-
- restore_cache: { keys: ['bundle-{{
|
36
|
+
- restore_cache: { keys: ['bundle-{{ checksum "Gemfile.lock" }}'] }
|
34
37
|
- run: bundle exec rubocop
|
35
38
|
|
36
39
|
tests:
|
@@ -40,9 +43,17 @@ jobs:
|
|
40
43
|
- *elasticsearch_container
|
41
44
|
steps:
|
42
45
|
- checkout
|
43
|
-
- restore_cache: { keys: ['bundle-{{
|
46
|
+
- restore_cache: { keys: ['bundle-{{ checksum "Gemfile.lock" }}'] }
|
47
|
+
- run:
|
48
|
+
name: Wait for ES to be ready
|
49
|
+
command: |
|
50
|
+
until curl $ELASTICSEARCH_URL/_cat/health | egrep '(green|yellow)' 2>&1 > /dev/null; do
|
51
|
+
echo -n .
|
52
|
+
sleep 1
|
53
|
+
done
|
44
54
|
- run: |
|
45
55
|
bundle exec rspec --pattern "**/*_spec.rb" --format "progress"
|
56
|
+
|
46
57
|
workflows:
|
47
58
|
version: 2
|
48
59
|
build:
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
TargetRubyVersion: 2.4
|
3
5
|
|
@@ -5,6 +7,7 @@ AllCops:
|
|
5
7
|
Metrics/BlockLength:
|
6
8
|
Exclude:
|
7
9
|
- '*.gemspec'
|
10
|
+
- 'spec/**/*'
|
8
11
|
|
9
12
|
# Configuration parameters: CountComments.
|
10
13
|
Metrics/MethodLength:
|
@@ -18,4 +21,4 @@ Style/Documentation:
|
|
18
21
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
19
22
|
# URISchemes: http, https
|
20
23
|
Metrics/LineLength:
|
21
|
-
Max:
|
24
|
+
Max: 100
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-05-27 17:11:31 +0100 using RuboCop version 0.52.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Lint/ShadowingOuterLocalVariable:
|
11
|
+
Exclude:
|
12
|
+
- 'lib/zelastic/indexer.rb'
|
13
|
+
|
14
|
+
# Offense count: 1
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Max: 17
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Max: 83
|
22
|
+
|
23
|
+
# Offense count: 4
|
24
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
25
|
+
# URISchemes: http, https
|
26
|
+
Metrics/LineLength:
|
27
|
+
Max: 146
|
28
|
+
|
29
|
+
# Offense count: 1
|
30
|
+
Naming/AccessorMethodName:
|
31
|
+
Exclude:
|
32
|
+
- 'spec/zelastic/indexer_spec.rb'
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zelastic (0.
|
4
|
+
zelastic (0.4.0)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
@@ -23,10 +23,22 @@ GEM
|
|
23
23
|
coderay (1.1.2)
|
24
24
|
concurrent-ruby (1.0.5)
|
25
25
|
diff-lcs (1.3)
|
26
|
+
elasticsearch (6.0.2)
|
27
|
+
elasticsearch-api (= 6.0.2)
|
28
|
+
elasticsearch-transport (= 6.0.2)
|
29
|
+
elasticsearch-api (6.0.2)
|
30
|
+
multi_json
|
31
|
+
elasticsearch-transport (6.0.2)
|
32
|
+
faraday
|
33
|
+
multi_json
|
34
|
+
faraday (0.15.2)
|
35
|
+
multipart-post (>= 1.2, < 3)
|
26
36
|
i18n (0.9.1)
|
27
37
|
concurrent-ruby (~> 1.0)
|
28
38
|
method_source (0.9.0)
|
29
39
|
minitest (5.11.1)
|
40
|
+
multi_json (1.13.1)
|
41
|
+
multipart-post (2.0.0)
|
30
42
|
parallel (1.12.1)
|
31
43
|
parser (2.4.0.2)
|
32
44
|
ast (~> 2.3)
|
@@ -68,6 +80,7 @@ PLATFORMS
|
|
68
80
|
DEPENDENCIES
|
69
81
|
activerecord
|
70
82
|
bundler
|
83
|
+
elasticsearch
|
71
84
|
pry
|
72
85
|
rake
|
73
86
|
rspec
|
@@ -75,4 +88,4 @@ DEPENDENCIES
|
|
75
88
|
zelastic!
|
76
89
|
|
77
90
|
BUNDLED WITH
|
78
|
-
1.16.
|
91
|
+
1.16.2
|
@@ -91,7 +91,9 @@ module Zelastic
|
|
91
91
|
logger.info('Nothing to do: no old indices')
|
92
92
|
return
|
93
93
|
end
|
94
|
-
logger.info(
|
94
|
+
logger.info(
|
95
|
+
"Deleting #{indices_to_delete.count} old indices: #{indices_to_delete.join(', ')}"
|
96
|
+
)
|
95
97
|
client.indices.delete(index: indices_to_delete)
|
96
98
|
end
|
97
99
|
# rubocop:enable Metrics/AbcSize
|
data/lib/zelastic/indexer.rb
CHANGED
@@ -5,10 +5,8 @@ module Zelastic
|
|
5
5
|
class IndexingError < StandardError
|
6
6
|
attr_reader :errors
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@errors =
|
10
|
-
item['error'] || item.fetch('index', {})['error']
|
11
|
-
end.compact
|
8
|
+
def initialize(errors)
|
9
|
+
@errors = errors
|
12
10
|
super("Errors indexing: #{errors.join(', ')}")
|
13
11
|
end
|
14
12
|
end
|
@@ -103,9 +101,33 @@ module Zelastic
|
|
103
101
|
commands = indices.flat_map { |index| yield(index) }
|
104
102
|
|
105
103
|
current_client.bulk(body: commands).tap do |result|
|
106
|
-
|
104
|
+
check_errors!(result)
|
107
105
|
end
|
108
106
|
end
|
109
107
|
end
|
108
|
+
|
109
|
+
def check_errors!(result)
|
110
|
+
return false unless result['errors']
|
111
|
+
|
112
|
+
errors = result['items']
|
113
|
+
.map { |item| item['error'] || item.fetch('index', {})['error'] }
|
114
|
+
.compact
|
115
|
+
|
116
|
+
ignorable_errors, important_errors = errors
|
117
|
+
.partition { |error| ignorable_error?(error) }
|
118
|
+
|
119
|
+
logger.warn("Ignoring #{ignorable_errors.count} version conflicts") if ignorable_errors.any?
|
120
|
+
|
121
|
+
return unless important_errors.any?
|
122
|
+
raise IndexingError, important_errors
|
123
|
+
end
|
124
|
+
|
125
|
+
def ignorable_error?(error)
|
126
|
+
# rubocop:disable Metrics/LineLength
|
127
|
+
regexp = /^\[#{config.type}\]\[\d+\]: version conflict, current version \[\d+\] is higher or equal to the one provided \[\d+\]$/
|
128
|
+
# rubocop:enable Metrics/LineLength
|
129
|
+
error['type'] == 'version_conflict_engine_exception' &&
|
130
|
+
error['reason'] =~ regexp
|
131
|
+
end
|
110
132
|
end
|
111
133
|
end
|
data/lib/zelastic/version.rb
CHANGED
data/zelastic.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'activerecord'
|
29
29
|
spec.add_development_dependency 'bundler'
|
30
|
+
spec.add_development_dependency 'elasticsearch'
|
30
31
|
spec.add_development_dependency 'pry'
|
31
32
|
spec.add_development_dependency 'rake'
|
32
33
|
spec.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zelastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carwow Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: elasticsearch
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +133,8 @@ files:
|
|
119
133
|
- ".gitignore"
|
120
134
|
- ".rspec"
|
121
135
|
- ".rubocop.yml"
|
136
|
+
- ".rubocop_todo.yml"
|
137
|
+
- CHANGELOG.md
|
122
138
|
- Gemfile
|
123
139
|
- Gemfile.lock
|
124
140
|
- LICENSE.txt
|
@@ -152,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
168
|
version: '0'
|
153
169
|
requirements: []
|
154
170
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.6.14.1
|
156
172
|
signing_key:
|
157
173
|
specification_version: 4
|
158
174
|
summary: Zero-downtime (re-)indexing of ActiveRecord models into Elasticsearch.
|