elasticsearch-transport 7.1.0 → 7.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -9
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +175 -76
- data/Rakefile +1 -1
- data/elasticsearch-transport.gemspec +42 -60
- data/lib/elasticsearch/transport/client.rb +154 -57
- data/lib/elasticsearch/transport/meta_header.rb +135 -0
- data/lib/elasticsearch/transport/redacted.rb +1 -1
- data/lib/elasticsearch/transport/transport/base.rb +93 -18
- data/lib/elasticsearch/transport/transport/connections/collection.rb +3 -6
- data/lib/elasticsearch/transport/transport/connections/connection.rb +8 -6
- data/lib/elasticsearch/transport/transport/connections/selector.rb +18 -6
- data/lib/elasticsearch/transport/transport/errors.rb +1 -1
- data/lib/elasticsearch/transport/transport/http/curb.rb +26 -9
- data/lib/elasticsearch/transport/transport/http/faraday.rb +27 -5
- data/lib/elasticsearch/transport/transport/http/manticore.rb +25 -10
- data/lib/elasticsearch/transport/transport/loggable.rb +1 -1
- data/lib/elasticsearch/transport/transport/response.rb +1 -2
- data/lib/elasticsearch/transport/transport/serializer/multi_json.rb +1 -1
- data/lib/elasticsearch/transport/transport/sniffer.rb +20 -12
- data/lib/elasticsearch/transport/version.rb +2 -2
- data/lib/elasticsearch/transport.rb +1 -1
- data/lib/elasticsearch-transport.rb +1 -1
- data/spec/elasticsearch/connections/collection_spec.rb +266 -0
- data/spec/elasticsearch/connections/selector_spec.rb +174 -0
- data/spec/elasticsearch/transport/base_spec.rb +197 -13
- data/spec/elasticsearch/transport/client_spec.rb +945 -118
- data/spec/elasticsearch/transport/meta_header_spec.rb +265 -0
- data/spec/elasticsearch/transport/sniffer_spec.rb +1 -14
- data/spec/spec_helper.rb +25 -1
- data/test/integration/transport_test.rb +15 -2
- data/test/profile/client_benchmark_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/connection_test.rb +8 -3
- data/test/unit/response_test.rb +2 -2
- data/test/unit/serializer_test.rb +1 -1
- data/test/unit/transport_base_test.rb +2 -2
- data/test/unit/transport_curb_test.rb +2 -2
- data/test/unit/transport_faraday_test.rb +3 -3
- data/test/unit/transport_manticore_test.rb +30 -14
- metadata +87 -60
- data/test/unit/connection_collection_test.rb +0 -147
- data/test/unit/connection_selector_test.rb +0 -81
@@ -1,81 +0,0 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
-
# license agreements. See the NOTICE file distributed with
|
3
|
-
# this work for additional information regarding copyright
|
4
|
-
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
-
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
-
# not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
require 'test_helper'
|
19
|
-
|
20
|
-
class Elasticsearch::Transport::Transport::Connections::SelectorTest < Minitest::Test
|
21
|
-
include Elasticsearch::Transport::Transport::Connections::Selector
|
22
|
-
|
23
|
-
class DummyStrategySelector
|
24
|
-
include Elasticsearch::Transport::Transport::Connections::Selector::Base
|
25
|
-
end
|
26
|
-
|
27
|
-
class BackupStrategySelector
|
28
|
-
include Elasticsearch::Transport::Transport::Connections::Selector::Base
|
29
|
-
|
30
|
-
def select(options={})
|
31
|
-
connections.reject do |c|
|
32
|
-
c.host[:attributes] && c.host[:attributes][:backup]
|
33
|
-
end.send( defined?(RUBY_VERSION) && RUBY_VERSION > '1.9' ? :sample : :choice)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "Connection selector" do
|
38
|
-
|
39
|
-
should "be initialized with connections" do
|
40
|
-
assert_equal [1, 2], Random.new(:connections => [1, 2]).connections
|
41
|
-
end
|
42
|
-
|
43
|
-
should "have the abstract select method" do
|
44
|
-
assert_raise(NoMethodError) { DummyStrategySelector.new.select }
|
45
|
-
end
|
46
|
-
|
47
|
-
context "in random strategy" do
|
48
|
-
setup do
|
49
|
-
@selector = Random.new :connections => ['A', 'B', 'C']
|
50
|
-
end
|
51
|
-
|
52
|
-
should "pick a connection" do
|
53
|
-
assert_not_nil @selector.select
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "in round-robin strategy" do
|
58
|
-
setup do
|
59
|
-
@selector = RoundRobin.new :connections => ['A', 'B', 'C']
|
60
|
-
end
|
61
|
-
|
62
|
-
should "rotate over connections" do
|
63
|
-
assert_equal 'A', @selector.select
|
64
|
-
assert_equal 'B', @selector.select
|
65
|
-
assert_equal 'C', @selector.select
|
66
|
-
assert_equal 'A', @selector.select
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "with a custom strategy" do
|
71
|
-
|
72
|
-
should "return proper connection" do
|
73
|
-
selector = BackupStrategySelector.new :connections => [ stub(:host => { :hostname => 'host1' }),
|
74
|
-
stub(:host => { :hostname => 'host2', :attributes => { :backup => true }}) ]
|
75
|
-
10.times { assert_equal 'host1', selector.select.host[:hostname] }
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|