solrb 0.2.3 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/reviewdog.yml +20 -0
  3. data/.github/workflows/tests.yaml +37 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +10 -6
  6. data/README.md +47 -0
  7. data/lib/solr.rb +21 -1
  8. data/lib/solr/cloud/configuration.rb +2 -1
  9. data/lib/solr/cloud/helper_methods.rb +1 -1
  10. data/lib/solr/commands.rb +3 -2
  11. data/lib/solr/commit/request.rb +15 -5
  12. data/lib/solr/configuration.rb +27 -5
  13. data/lib/solr/connection.rb +6 -4
  14. data/lib/solr/data_import/request.rb +7 -1
  15. data/lib/solr/delete/request.rb +7 -1
  16. data/lib/solr/errors/solr_connection_failed_error.rb +3 -2
  17. data/lib/solr/helper_methods.rb +11 -0
  18. data/lib/solr/indexing/request.rb +7 -1
  19. data/lib/solr/master_slave/configuration.rb +38 -0
  20. data/lib/solr/master_slave/helper_methods.rb +25 -0
  21. data/lib/solr/master_slave/nodes_gray_list/disabled.rb +21 -0
  22. data/lib/solr/master_slave/nodes_gray_list/in_memory.rb +47 -0
  23. data/lib/solr/query/handler.rb +8 -7
  24. data/lib/solr/query/http_request_builder.rb +6 -12
  25. data/lib/solr/query/request.rb +19 -2
  26. data/lib/solr/query/request/boosting/dictionary_boost_function.rb +4 -3
  27. data/lib/solr/query/request/facet.rb +5 -2
  28. data/lib/solr/request/cloud/first_shard_leader_node_selection_strategy.rb +27 -0
  29. data/lib/solr/request/cloud/leader_node_selection_strategy.rb +21 -0
  30. data/lib/solr/request/default_node_selection_strategy.rb +2 -1
  31. data/lib/solr/request/master_slave/master_node_selection_strategy.rb +12 -0
  32. data/lib/solr/request/node_selection_strategy.rb +6 -0
  33. data/lib/solr/request/runner.rb +18 -11
  34. data/lib/solr/response/parser.rb +1 -1
  35. data/lib/solr/support/url_helper.rb +8 -3
  36. data/lib/solr/version.rb +1 -1
  37. data/solrb.gemspec +2 -3
  38. metadata +25 -35
  39. data/.circleci/config.yml +0 -69
  40. data/.circleci/run-with-local-config.sh +0 -7
  41. data/Gemfile.lock +0 -83
  42. data/lib/solr/request/first_shard_leader_node_selection_strategy.rb +0 -24
  43. data/lib/solr/request/leader_node_selection_strategy.rb +0 -18
@@ -12,7 +12,7 @@ module Solr
12
12
  def call
13
13
  # 404 is a special case, it didn't hit Solr (more likely than not)
14
14
  return not_found_response if @raw_response.status == 404
15
- parsed_body = JSON.parse(@raw_response.body).freeze
15
+ parsed_body = @raw_response.body ? JSON.parse(@raw_response.body).freeze : {}
16
16
  http_status = parse_http_status
17
17
  header = parse_header(parsed_body)
18
18
  solr_error = parse_solr_error(parsed_body)
@@ -18,11 +18,16 @@ module Solr
18
18
  end
19
19
 
20
20
  def core_url
21
- Solr.cloud_enabled? ? solr_cloud_url : current_core.uri
21
+ if Solr.cloud_enabled? || Solr.master_slave_enabled?
22
+ solr_cloud_or_master_slave_url
23
+ else
24
+ current_core.uri
25
+ end
22
26
  end
23
27
 
24
- def solr_cloud_url
25
- File.join(Solr.active_nodes_for(collection: current_core.name.to_s).first, current_core.name.to_s)
28
+ def solr_cloud_or_master_slave_url
29
+ url = Solr.active_nodes_for(collection: current_core.name.to_s).first
30
+ File.join(url, current_core.name.to_s)
26
31
  end
27
32
 
28
33
  def current_core
data/lib/solr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Solr
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.8'.freeze
3
3
  end
data/solrb.gemspec CHANGED
@@ -24,12 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'addressable'
25
25
  spec.add_runtime_dependency 'faraday'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'bundler'
28
28
  spec.add_development_dependency 'pry'
29
29
  spec.add_development_dependency 'pry-byebug'
30
30
  spec.add_development_dependency 'rake', '~> 10.0'
31
31
  spec.add_development_dependency 'rspec', '~> 3.0'
32
- spec.add_development_dependency 'rspec_junit_formatter'
33
- spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'rubocop', '~> 0.80.1'
34
33
  spec.add_development_dependency 'simplecov'
35
34
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Luz
8
8
  - Valentin Vasilyev
9
9
  - Vladislav Syabruk
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-04-04 00:00:00.000000000 Z
13
+ date: 2021-05-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -44,16 +44,16 @@ dependencies:
44
44
  name: bundler
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '1.16'
49
+ version: '0'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: '1.16'
56
+ version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: pry
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -110,34 +110,20 @@ dependencies:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.0'
113
- - !ruby/object:Gem::Dependency
114
- name: rspec_junit_formatter
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
113
  - !ruby/object:Gem::Dependency
128
114
  name: rubocop
129
115
  requirement: !ruby/object:Gem::Requirement
130
116
  requirements:
131
- - - ">="
117
+ - - "~>"
132
118
  - !ruby/object:Gem::Version
133
- version: '0'
119
+ version: 0.80.1
134
120
  type: :development
135
121
  prerelease: false
136
122
  version_requirements: !ruby/object:Gem::Requirement
137
123
  requirements:
138
- - - ">="
124
+ - - "~>"
139
125
  - !ruby/object:Gem::Version
140
- version: '0'
126
+ version: 0.80.1
141
127
  - !ruby/object:Gem::Dependency
142
128
  name: simplecov
143
129
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +138,7 @@ dependencies:
152
138
  - - ">="
153
139
  - !ruby/object:Gem::Version
154
140
  version: '0'
155
- description:
141
+ description:
156
142
  email:
157
143
  - adriano.luz@machinio.com
158
144
  - valentin@machinio.com
@@ -161,13 +147,12 @@ executables: []
161
147
  extensions: []
162
148
  extra_rdoc_files: []
163
149
  files:
164
- - ".circleci/config.yml"
165
- - ".circleci/run-with-local-config.sh"
150
+ - ".github/workflows/reviewdog.yml"
151
+ - ".github/workflows/tests.yaml"
166
152
  - ".gitignore"
167
153
  - ".rspec"
168
154
  - ".rubocop.yml"
169
155
  - Gemfile
170
- - Gemfile.lock
171
156
  - LICENSE.txt
172
157
  - README.md
173
158
  - Rakefile
@@ -198,8 +183,13 @@ files:
198
183
  - lib/solr/errors/solr_url_not_defined_error.rb
199
184
  - lib/solr/errors/zookeeper_required.rb
200
185
  - lib/solr/grouped_document_collection.rb
186
+ - lib/solr/helper_methods.rb
201
187
  - lib/solr/indexing/document.rb
202
188
  - lib/solr/indexing/request.rb
189
+ - lib/solr/master_slave/configuration.rb
190
+ - lib/solr/master_slave/helper_methods.rb
191
+ - lib/solr/master_slave/nodes_gray_list/disabled.rb
192
+ - lib/solr/master_slave/nodes_gray_list/in_memory.rb
203
193
  - lib/solr/query/handler.rb
204
194
  - lib/solr/query/http_request_builder.rb
205
195
  - lib/solr/query/request.rb
@@ -235,10 +225,11 @@ files:
235
225
  - lib/solr/query/response/field_facets.rb
236
226
  - lib/solr/query/response/parser.rb
237
227
  - lib/solr/query/response/spellcheck.rb
228
+ - lib/solr/request/cloud/first_shard_leader_node_selection_strategy.rb
229
+ - lib/solr/request/cloud/leader_node_selection_strategy.rb
238
230
  - lib/solr/request/default_node_selection_strategy.rb
239
- - lib/solr/request/first_shard_leader_node_selection_strategy.rb
240
231
  - lib/solr/request/http_request.rb
241
- - lib/solr/request/leader_node_selection_strategy.rb
232
+ - lib/solr/request/master_slave/master_node_selection_strategy.rb
242
233
  - lib/solr/request/node_selection_strategy.rb
243
234
  - lib/solr/request/runner.rb
244
235
  - lib/solr/response.rb
@@ -259,7 +250,7 @@ homepage: https://github.com/machinio/solrb
259
250
  licenses:
260
251
  - MIT
261
252
  metadata: {}
262
- post_install_message:
253
+ post_install_message:
263
254
  rdoc_options: []
264
255
  require_paths:
265
256
  - lib
@@ -274,9 +265,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
265
  - !ruby/object:Gem::Version
275
266
  version: '0'
276
267
  requirements: []
277
- rubyforge_project:
278
- rubygems_version: 2.7.6
279
- signing_key:
268
+ rubygems_version: 3.0.3
269
+ signing_key:
280
270
  specification_version: 4
281
271
  summary: Solr Ruby client with a nice object-oriented API
282
272
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,69 +0,0 @@
1
- # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
- version: 2
6
- jobs:
7
- build:
8
- docker:
9
- # primary image where all specs are run
10
- - image: circleci/ruby:2.5.1-node-browsers
11
- environment:
12
- SOLR_URL: http://localhost:8983/solr/test-core
13
- # service images that primary image will use
14
- - image: solr:7.4.0
15
-
16
- working_directory: ~/repo
17
-
18
- steps:
19
- - checkout
20
-
21
- # Download and cache dependencies
22
- - restore_cache:
23
- keys:
24
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
25
- # fallback to using the latest cache if no exact match is found
26
- - v1-dependencies-
27
-
28
- - run:
29
- name: install dependencies
30
- command: |
31
- bundle install --jobs=4 --retry=3 --path vendor/bundle
32
-
33
- - save_cache:
34
- paths:
35
- - ./vendor/bundle
36
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
37
-
38
- - run:
39
- name: Wait for Solr
40
- command: dockerize -wait tcp://localhost:8983 -timeout 1m
41
-
42
- - run:
43
- name: Create a test core
44
- command: curl 'http://localhost:8983/solr/admin/cores?action=CREATE&name=test-core&configSet=_default'
45
-
46
- - run:
47
- name: Disable field type guessing
48
- command: |
49
- curl http://localhost:8983/solr/test-core/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}'
50
-
51
-
52
- - run:
53
- name: run tests
54
- command: |
55
- mkdir /tmp/test-results
56
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
57
-
58
- bundle exec rspec --format progress \
59
- --format RspecJunitFormatter \
60
- --out /tmp/test-results/rspec.xml \
61
- --format progress \
62
- $TEST_FILES
63
-
64
- # collect reports
65
- - store_test_results:
66
- path: /tmp/test-results
67
- - store_artifacts:
68
- path: /tmp/test-results
69
- destination: test-results
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- curl --user ${CIRCLE_TOKEN}: \
3
- --request POST \
4
- --form revision=67d7c5937163 \
5
- --form config=@config.yml \
6
- --form notify=false \
7
- https://circleci.com/api/v1.1/project/github/machinio/solrb/tree/master
data/Gemfile.lock DELETED
@@ -1,83 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- solrb (0.2.2)
5
- addressable
6
- faraday
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.6.0)
12
- public_suffix (>= 2.0.2, < 4.0)
13
- ast (2.4.0)
14
- byebug (10.0.2)
15
- coderay (1.1.2)
16
- diff-lcs (1.3)
17
- docile (1.3.1)
18
- faraday (0.15.4)
19
- multipart-post (>= 1.2, < 3)
20
- jaro_winkler (1.5.1)
21
- json (2.1.0)
22
- method_source (0.9.0)
23
- multipart-post (2.0.0)
24
- parallel (1.12.1)
25
- parser (2.5.1.2)
26
- ast (~> 2.4.0)
27
- powerpack (0.1.2)
28
- pry (0.11.3)
29
- coderay (~> 1.1.0)
30
- method_source (~> 0.9.0)
31
- pry-byebug (3.6.0)
32
- byebug (~> 10.0)
33
- pry (~> 0.10)
34
- public_suffix (3.0.3)
35
- rainbow (3.0.0)
36
- rake (10.5.0)
37
- rspec (3.8.0)
38
- rspec-core (~> 3.8.0)
39
- rspec-expectations (~> 3.8.0)
40
- rspec-mocks (~> 3.8.0)
41
- rspec-core (3.8.0)
42
- rspec-support (~> 3.8.0)
43
- rspec-expectations (3.8.1)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.8.0)
46
- rspec-mocks (3.8.0)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.8.0)
49
- rspec-support (3.8.0)
50
- rspec_junit_formatter (0.4.1)
51
- rspec-core (>= 2, < 4, != 2.12.0)
52
- rubocop (0.59.1)
53
- jaro_winkler (~> 1.5.1)
54
- parallel (~> 1.10)
55
- parser (>= 2.5, != 2.5.1.1)
56
- powerpack (~> 0.1)
57
- rainbow (>= 2.2.2, < 4.0)
58
- ruby-progressbar (~> 1.7)
59
- unicode-display_width (~> 1.0, >= 1.0.1)
60
- ruby-progressbar (1.10.0)
61
- simplecov (0.16.1)
62
- docile (~> 1.1)
63
- json (>= 1.8, < 3)
64
- simplecov-html (~> 0.10.0)
65
- simplecov-html (0.10.2)
66
- unicode-display_width (1.4.0)
67
-
68
- PLATFORMS
69
- ruby
70
-
71
- DEPENDENCIES
72
- bundler (~> 1.16)
73
- pry
74
- pry-byebug
75
- rake (~> 10.0)
76
- rspec (~> 3.0)
77
- rspec_junit_formatter
78
- rubocop
79
- simplecov
80
- solrb!
81
-
82
- BUNDLED WITH
83
- 1.16.6
@@ -1,24 +0,0 @@
1
- module Solr
2
- module Request
3
- class FirstShardLeaderNodeSelectionStrategy < NodeSelectionStrategy
4
- def call
5
- leader = first_shard_leader_replica_node_for(collection: collection_name)
6
- replicas = solr_cloud_active_nodes_urls.shuffle
7
- ([leader] + replicas).flatten.uniq
8
- end
9
-
10
- private
11
-
12
- def first_shard_leader_replica_node_for(collection:)
13
- shards = Solr.shards_for(collection: collection)
14
- return unless shards
15
- first_shard_name = shards.sort.first
16
- Solr.leader_replica_node_for(collection: collection, shard: first_shard_name)
17
- end
18
-
19
- def solr_cloud_active_nodes_urls
20
- Solr.active_nodes_for(collection: collection_name)
21
- end
22
- end
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- module Solr
2
- module Request
3
- class LeaderNodeSelectionStrategy < NodeSelectionStrategy
4
- def call
5
- [leader_replica_node_for(collection: collection_name)]
6
- end
7
-
8
- private
9
-
10
- def leader_replica_node_for(collection:)
11
- shards = Solr.shards_for(collection: collection)
12
- return unless shards
13
- first_shard_name = shards.sort.first
14
- Solr.leader_replica_node_for(collection: collection, shard: first_shard_name)
15
- end
16
- end
17
- end
18
- end