elasticsearch-transport 0.4.11 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,14 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in elasticsearch-transport.gemspec
4
4
  gemspec
5
5
 
6
- if File.exists? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemspec", __FILE__)
7
- gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
8
- end
9
-
10
- if File.exists? File.expand_path("../../elasticsearch-extensions/elasticsearch-extensions.gemspec", __FILE__)
6
+ if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
11
7
  gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => true
12
8
  end
13
-
14
- if File.exists? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
15
- gem 'elasticsearch', :path => File.expand_path("../../elasticsearch", __FILE__), :require => false
16
- end
@@ -57,8 +57,6 @@ module Elasticsearch
57
57
  #
58
58
  # @option arguments [Boolean] :reload_on_failure Reload connections after failure (false by default)
59
59
  #
60
- # @option arguments [Hash] :transport_options Options to be passed to the `Faraday::Connection` constructor
61
- #
62
60
  # @option arguments [Constant] :transport_class A specific transport class to use, will be initialized by
63
61
  # the client and passed hosts and all arguments
64
62
  #
@@ -80,7 +78,6 @@ module Elasticsearch
80
78
  arguments[:retry_on_failure] ||= false
81
79
  arguments[:reload_on_failure] ||= false
82
80
  arguments[:randomize_hosts] ||= false
83
- arguments[:transport_options] ||= {}
84
81
 
85
82
  @transport = arguments[:transport] || \
86
83
  transport_class.new(:hosts => __extract_hosts(hosts, arguments), :options => arguments)
@@ -177,13 +177,7 @@ module Elasticsearch
177
177
  begin
178
178
  tries += 1
179
179
  connection = get_connection or raise Error.new("Cannot get new connection from pool.")
180
-
181
- if connection.connection.respond_to?(:params) && connection.connection.params.respond_to?(:to_hash)
182
- params = connection.connection.params.merge(params.to_hash)
183
- end
184
-
185
180
  url = connection.full_url(path, params)
186
-
187
181
  response = block.call(connection, url)
188
182
 
189
183
  connection.healthy! if connection.failures > 0
@@ -28,12 +28,7 @@ module Elasticsearch
28
28
 
29
29
  connection.connection.http(method.to_sym)
30
30
 
31
- headers = {}
32
- headers['content-type'] = 'application/json' if connection.connection.header_str =~ /\/json/
33
-
34
- Response.new connection.connection.response_code,
35
- connection.connection.body_str,
36
- headers
31
+ Response.new connection.connection.response_code, connection.connection.body_str
37
32
  end
38
33
  end
39
34
 
@@ -39,7 +39,7 @@ module Elasticsearch
39
39
 
40
40
  Connections::Connection.new \
41
41
  :host => host,
42
- :connection => ::Faraday::Connection.new(url, (options[:transport_options] || {}), &@block )
42
+ :connection => ::Faraday::Connection.new( :url => url, &@block )
43
43
  },
44
44
  :selector_class => options[:selector_class],
45
45
  :selector => options[:selector]
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Transport
3
- VERSION = "0.4.11"
3
+ VERSION = "1.0.0.rc1"
4
4
  end
5
5
  end
@@ -32,20 +32,6 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
32
32
  client.perform_request 'GET', ''
33
33
  end
34
34
 
35
- should "allow to define connection parameters and pass them" do
36
- transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
37
- :hosts => [ { :host => 'localhost', :port => @port } ],
38
- :options => { :transport_options => {
39
- :params => { :format => 'yaml' }
40
- }
41
- }
42
-
43
- client = Elasticsearch::Transport::Client.new transport: transport
44
- response = client.perform_request 'GET', ''
45
-
46
- assert response.body.start_with?("---\n"), "Response body should be YAML: #{response.body.inspect}"
47
- end
48
-
49
35
  should "use the Curb client" do
50
36
  require 'curb'
51
37
  require 'elasticsearch/transport/transport/http/curb'
@@ -58,23 +44,6 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
58
44
  client = Elasticsearch::Transport::Client.new transport: transport
59
45
  client.perform_request 'GET', ''
60
46
  end unless JRUBY
61
-
62
- should "deserialize JSON responses in the Curb client" do
63
- require 'curb'
64
- require 'elasticsearch/transport/transport/http/curb'
65
-
66
- transport = Elasticsearch::Transport::Transport::HTTP::Curb.new \
67
- :hosts => [ { :host => 'localhost', :port => @port } ] do |curl|
68
- curl.verbose = true
69
- end
70
-
71
- client = Elasticsearch::Transport::Client.new transport: transport
72
- response = client.perform_request 'GET', ''
73
-
74
- assert_respond_to(response.body, :to_hash)
75
- assert_equal 200, response.body['status']
76
- assert_equal 'application/json', response.headers['content-type']
77
- end unless JRUBY
78
47
  end
79
48
 
80
49
  end
@@ -48,14 +48,6 @@ class Elasticsearch::Transport::ClientTest < Test::Unit::TestCase
48
48
  assert_respond_to client.transport.tracer, :info
49
49
  end
50
50
 
51
- should "initialize the default transport class" do
52
- Elasticsearch::Transport::Client::DEFAULT_TRANSPORT_CLASS.any_instance.
53
- unstub(:__build_connections)
54
-
55
- client = Elasticsearch::Client.new
56
- assert_match /Faraday/, client.transport.connections.first.connection.headers['User-Agent']
57
- end
58
-
59
51
  context "when passed hosts" do
60
52
  should "have localhost by default" do
61
53
  c = Elasticsearch::Transport::Client.new
@@ -270,14 +270,10 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
270
270
  context "logging" do
271
271
  setup do
272
272
  @transport = DummyTransportPerformer.new :options => { :logger => Logger.new('/dev/null') }
273
-
274
- fake_connection = stub :full_url => 'localhost:9200/_search?size=1',
275
- :host => 'localhost',
276
- :connection => stub_everything,
277
- :failures => 0,
278
- :healthy! => true
279
-
280
- @transport.stubs(:get_connection).returns(fake_connection)
273
+ @transport.stubs(:get_connection).returns stub :full_url => 'localhost:9200/_search?size=1',
274
+ :host => 'localhost',
275
+ :failures => 0,
276
+ :healthy! => true
281
277
  @transport.serializer.stubs(:load).returns 'foo' => 'bar'
282
278
  @transport.serializer.stubs(:dump).returns '{"foo":"bar"}'
283
279
  end
@@ -318,14 +314,10 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
318
314
  context "tracing" do
319
315
  setup do
320
316
  @transport = DummyTransportPerformer.new :options => { :tracer => Logger.new('/dev/null') }
321
-
322
- fake_connection = stub :full_url => 'localhost:9200/_search?size=1',
323
- :host => 'localhost',
324
- :connection => stub_everything,
325
- :failures => 0,
326
- :healthy! => true
327
-
328
- @transport.stubs(:get_connection).returns(fake_connection)
317
+ @transport.stubs(:get_connection).returns stub :full_url => 'localhost:9200/_search?size=1',
318
+ :host => 'localhost',
319
+ :failures => 0,
320
+ :healthy! => true
329
321
  @transport.serializer.stubs(:load).returns 'foo' => 'bar'
330
322
  @transport.serializer.stubs(:dump).returns <<-JSON.gsub(/^ /, '')
331
323
  {
@@ -1,10 +1,10 @@
1
- require 'test_helper'
2
-
3
1
  if JRUBY
4
2
  puts "'#{File.basename(__FILE__)}' not supported on JRuby #{RUBY_VERSION}"
5
3
  exit(0)
6
4
  end
7
5
 
6
+
7
+ require 'test_helper'
8
8
  require 'elasticsearch/transport/transport/http/curb'
9
9
  require 'curb'
10
10
 
@@ -53,16 +53,6 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
53
53
  @transport.perform_request 'POST', '/', {}, '{"foo":"bar"}'
54
54
  end
55
55
 
56
- should "set application/json header" do
57
- @transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
58
- @transport.connections.first.connection.expects(:body_str).returns('{"foo":"bar"}')
59
- @transport.connections.first.connection.expects(:header_str).returns('HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=UTF-8\r\nContent-Length: 311\r\n\r\n')
60
-
61
- response = @transport.perform_request 'GET', '/'
62
-
63
- assert_equal 'application/json', response.headers['content-type']
64
- end
65
-
66
56
  should "handle HTTP methods" do
67
57
  @transport.connections.first.connection.expects(:http).with(:HEAD).returns(stub_everything)
68
58
  @transport.connections.first.connection.expects(:http).with(:GET).returns(stub_everything)
@@ -58,71 +58,15 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
58
58
  @transport.connections.selector
59
59
  end
60
60
 
61
- should "pass a configuration block to the Faraday constructor" do
61
+ should "allow to set options for Faraday" do
62
62
  config_block = lambda do |f|
63
63
  f.response :logger
64
- f.path_prefix = '/moo'
65
64
  end
66
65
 
67
66
  transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ], &config_block
68
67
 
69
- handlers = transport.connections.first.connection.builder.handlers
70
-
71
- assert_equal 1, handlers.size
72
- assert handlers.include?(::Faraday::Response::Logger), "#{handlers.inspect} does not include <::Faraday::Adapter::Logger>"
73
-
74
- assert_equal '/moo', transport.connections.first.connection.path_prefix
75
- assert_equal 'http://foobar:1234/moo', transport.connections.first.connection.url_prefix.to_s
76
- end
77
-
78
- should "pass transport_options to the Faraday constructor" do
79
- transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ],
80
- :options => { :transport_options => {
81
- :request => { :open_timeout => 1 },
82
- :headers => { :foo_bar => 'bar' },
83
- :ssl => { :verify => false }
84
- }
85
- }
86
-
87
- assert_equal 1, transport.connections.first.connection.options.open_timeout
88
- assert_equal 'bar', transport.connections.first.connection.headers['Foo-Bar']
89
- assert_equal false, transport.connections.first.connection.ssl.verify?
90
- end
91
-
92
- should "merge in parameters defined in the Faraday connection parameters" do
93
- transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ],
94
- :options => { :transport_options => {
95
- :params => { :format => 'yaml' }
96
- }
97
- }
98
- # transport.logger = Logger.new(STDERR)
99
-
100
- transport.connections.first.connection.expects(:run_request).
101
- with do |method, url, params, body|
102
- assert_match /\?format=yaml/, url
103
- true
104
- end.
105
- returns(stub_everything)
106
-
107
- transport.perform_request 'GET', ''
108
- end
109
-
110
- should "not overwrite request parameters with the Faraday connection parameters" do
111
- transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ],
112
- :options => { :transport_options => {
113
- :params => { :format => 'yaml' }
114
- }
115
- }
116
- # transport.logger = Logger.new(STDERR)
117
-
118
- transport.connections.first.connection.expects(:run_request).
119
- with do |method, url, params, body|
120
- assert_match /\?format=json/, url
121
- true
122
- end.
123
- returns(stub_everything)
124
-
125
- transport.perform_request 'GET', '', { :format => 'json' }
68
+ handlers = transport.connections.first.connection.instance_variable_get(:@builder).instance_variable_get(:@handlers)
69
+ assert handlers.include?(::Faraday::Response::Logger), "#{handlers.inspect} does not include <::Faraday::Adapter::Typhoeus>"
126
70
  end
127
71
 
128
72
  should "set the credentials if passed" do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
5
- prerelease:
4
+ version: 1.0.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karel Minarik
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-11 00:00:00.000000000 Z
12
+ date: 2014-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -393,9 +393,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  required_rubygems_version: !ruby/object:Gem::Requirement
394
394
  none: false
395
395
  requirements:
396
- - - ! '>='
396
+ - - ! '>'
397
397
  - !ruby/object:Gem::Version
398
- version: '0'
398
+ version: 1.3.1
399
399
  requirements: []
400
400
  rubyforge_project:
401
401
  rubygems_version: 1.8.23