elasticsearch-transport 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +17 -0
- data/elasticsearch-transport.gemspec +1 -2
- data/lib/elasticsearch/transport/client.rb +5 -3
- data/lib/elasticsearch/transport/transport/http/curb.rb +1 -1
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/test/unit/client_test.rb +9 -5
- data/test/unit/transport_curb_test.rb +4 -0
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTYyMTcyOTVlNjgyNTAzMzk4YTRmNDhkNmNmYTJmZTVjNTEwYjQwOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzBiOTgwYjA3NGIxYmNhZTU0YTI3NGY2NWRkZmRjMjk2MzEzYzViZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmYwMTBmYzE5NmJkYjhiOTUxMGIyOWQzZTkyNDYzZmM2MTkzMGE2YmM5YTdk
|
10
|
+
MjdlYmE4NDYyMWIzZWY5MTRmNDAyNDlkMjE1YmUwMmZkZDBlNjJlMTFmNDY5
|
11
|
+
YTRjMTE4M2RkZmU3ZTVmMjQ2OWI0NGU5MjBmZDRhY2EyMzVjN2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODEwMzczYzc3ODdhMmJlZGIxODkzNDRlMDY1MDJkOTBkOTBhMTBkYWRjYmE3
|
14
|
+
ODZmMmI5NjlhODg0MTg5OGUxYjQxNDQwY2E4MjkwNjE0MWM3ZDMwMDUzYTE0
|
15
|
+
ZTE3OTFjZmIwZjA4NTJmMmY2MmEyMDQzNmU2ODc5ZjFjZjY1ZGQ=
|
data/README.md
CHANGED
@@ -323,6 +323,23 @@ The serialization component is pluggable, though, so you can write your own by i
|
|
323
323
|
{Elasticsearch::Transport::Transport::Serializer::Base} module, implementing the required contract,
|
324
324
|
and passing it to the client as the `serializer_class` or `serializer` parameter.
|
325
325
|
|
326
|
+
### Exception Handling
|
327
|
+
|
328
|
+
The library defines a [number of exception classes](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-transport/lib/elasticsearch/transport/transport/errors.rb)
|
329
|
+
for various client and server errors, as well as unsuccessful HTTP responses,
|
330
|
+
making it possible to `rescue` specific exceptions with desired granularity.
|
331
|
+
|
332
|
+
The highest-level exception is {Elasticsearch::Transport::Transport::Error}
|
333
|
+
and will be raised for any generic client *or* server errors.
|
334
|
+
|
335
|
+
{Elasticsearch::Transport::Transport::ServerError} will be raised for server errors only.
|
336
|
+
|
337
|
+
As an example for response-specific errors, a `404` response status will raise
|
338
|
+
an {Elasticsearch::Transport::Transport::Errors::NotFound} exception.
|
339
|
+
|
340
|
+
Finally, {Elasticsearch::Transport::Transport::SnifferTimeoutError} will be raised
|
341
|
+
when connection reloading ("sniffing") times out.
|
342
|
+
|
326
343
|
## Development and Community
|
327
344
|
|
328
345
|
For local development, clone the repository and run `bundle install`. See `rake -T` for a list of
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.add_development_dependency "turn"
|
41
41
|
s.add_development_dependency "yard"
|
42
42
|
s.add_development_dependency "pry"
|
43
|
-
s.add_development_dependency "ci_reporter"
|
43
|
+
s.add_development_dependency "ci_reporter", "~> 1.9"
|
44
44
|
|
45
45
|
# Gems for testing integrations
|
46
46
|
s.add_development_dependency "curb" unless defined? JRUBY_VERSION
|
@@ -60,7 +60,6 @@ Gem::Specification.new do |s|
|
|
60
60
|
s.add_development_dependency "simplecov"
|
61
61
|
s.add_development_dependency "simplecov-rcov"
|
62
62
|
s.add_development_dependency "cane"
|
63
|
-
s.add_development_dependency "coveralls"
|
64
63
|
end
|
65
64
|
|
66
65
|
s.description = <<-DESC.gsub(/^ /, '')
|
@@ -33,6 +33,8 @@ module Elasticsearch
|
|
33
33
|
|
34
34
|
# Create a client connected to an Elasticsearch cluster.
|
35
35
|
#
|
36
|
+
# Specify the URL via arguments or set the `ELASTICSEARCH_URL` environment variable.
|
37
|
+
#
|
36
38
|
# @option arguments [String,Array] :hosts Single host passed as a String or Hash, or multiple hosts
|
37
39
|
# passed as an Array; `host` or `url` keys are also valid
|
38
40
|
#
|
@@ -73,7 +75,7 @@ module Elasticsearch
|
|
73
75
|
# {Elasticsearch::Transport::Transport::Connections::Selector::Base}.
|
74
76
|
#
|
75
77
|
def initialize(arguments={})
|
76
|
-
hosts
|
78
|
+
hosts = arguments[:hosts] || arguments[:host] || arguments[:url] || ENV.fetch('ELASTICSEARCH_URL', 'localhost:9200')
|
77
79
|
|
78
80
|
arguments[:logger] ||= arguments[:log] ? DEFAULT_LOGGER.call() : nil
|
79
81
|
arguments[:tracer] ||= arguments[:trace] ? DEFAULT_TRACER.call() : nil
|
@@ -114,8 +116,8 @@ module Elasticsearch
|
|
114
116
|
#
|
115
117
|
# @api private
|
116
118
|
#
|
117
|
-
def __extract_hosts(hosts_config
|
118
|
-
hosts_config =
|
119
|
+
def __extract_hosts(hosts_config, options={})
|
120
|
+
hosts_config = Array(hosts_config)
|
119
121
|
|
120
122
|
hosts = hosts_config.map do |host|
|
121
123
|
case host
|
@@ -70,7 +70,7 @@ module Elasticsearch
|
|
70
70
|
# @return [Array]
|
71
71
|
#
|
72
72
|
def host_unreachable_exceptions
|
73
|
-
[::Curl::Err::HostResolutionError, ::Curl::Err::ConnectionFailedError]
|
73
|
+
[::Curl::Err::HostResolutionError, ::Curl::Err::ConnectionFailedError, ::Curl::Err::GotNothingError, ::Curl::Err::RecvError, ::Curl::Err::SendError]
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
data/test/unit/client_test.rb
CHANGED
@@ -70,16 +70,20 @@ class Elasticsearch::Transport::ClientTest < Test::Unit::TestCase
|
|
70
70
|
assert_equal 'foobar', c2.transport.hosts.first[:host]
|
71
71
|
assert_equal 'foobar', c3.transport.hosts.first[:host]
|
72
72
|
end
|
73
|
+
|
73
74
|
end
|
74
75
|
|
75
|
-
context "
|
76
|
-
|
77
|
-
|
76
|
+
context "when the URL is set in the environment variable" do
|
77
|
+
setup { ENV['ELASTICSEARCH_URL'] = 'foobar' }
|
78
|
+
teardown { ENV.delete('ELASTICSEARCH_URL') }
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
should "use it" do
|
81
|
+
c = Elasticsearch::Transport::Client.new
|
82
|
+
assert_equal 'foobar', c.transport.hosts.first[:host]
|
81
83
|
end
|
84
|
+
end
|
82
85
|
|
86
|
+
context "extracting hosts" do
|
83
87
|
should "extract from string" do
|
84
88
|
hosts = @client.__extract_hosts 'myhost'
|
85
89
|
|
@@ -16,6 +16,10 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
|
|
16
16
|
@transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234 } ]
|
17
17
|
end
|
18
18
|
|
19
|
+
should "implement host_unreachable_exceptions" do
|
20
|
+
assert_instance_of Array, @transport.host_unreachable_exceptions
|
21
|
+
end
|
22
|
+
|
19
23
|
should "implement __build_connections" do
|
20
24
|
assert_equal 1, @transport.hosts.size
|
21
25
|
assert_equal 1, @transport.connections.size
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -168,16 +168,16 @@ dependencies:
|
|
168
168
|
name: ci_reporter
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
173
|
+
version: '1.9'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ~>
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '1.9'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: curb
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,20 +304,6 @@ dependencies:
|
|
304
304
|
- - ! '>='
|
305
305
|
- !ruby/object:Gem::Version
|
306
306
|
version: '0'
|
307
|
-
- !ruby/object:Gem::Dependency
|
308
|
-
name: coveralls
|
309
|
-
requirement: !ruby/object:Gem::Requirement
|
310
|
-
requirements:
|
311
|
-
- - ! '>='
|
312
|
-
- !ruby/object:Gem::Version
|
313
|
-
version: '0'
|
314
|
-
type: :development
|
315
|
-
prerelease: false
|
316
|
-
version_requirements: !ruby/object:Gem::Requirement
|
317
|
-
requirements:
|
318
|
-
- - ! '>='
|
319
|
-
- !ruby/object:Gem::Version
|
320
|
-
version: '0'
|
321
307
|
description: ! 'Ruby client for Elasticsearch. See the `elasticsearch` gem for full
|
322
308
|
integration.
|
323
309
|
|