elastic-transport 8.1.2 → 8.2.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/.github/workflows/license.yml +1 -1
- data/.github/workflows/tests.yml +47 -7
- data/.gitignore +1 -1
- data/CHANGELOG.md +6 -11
- data/Gemfile +4 -8
- data/Gemfile-faraday1.gemfile +39 -0
- data/README.md +1 -1
- data/Rakefile +48 -1
- data/elastic-transport.gemspec +5 -8
- data/lib/elastic/transport/client.rb +12 -10
- data/lib/elastic/transport/meta_header.rb +8 -8
- data/lib/elastic/transport/transport/base.rb +53 -50
- data/lib/elastic/transport/transport/errors.rb +2 -4
- data/lib/elastic/transport/transport/http/curb.rb +28 -25
- data/lib/elastic/transport/transport/http/faraday.rb +29 -27
- data/lib/elastic/transport/transport/http/manticore.rb +1 -1
- data/lib/elastic/transport/transport/response.rb +3 -2
- data/lib/elastic/transport/transport/sniffer.rb +1 -3
- data/lib/elastic/transport/version.rb +1 -1
- data/spec/elastic/transport/base_spec.rb +4 -2
- data/spec/elastic/transport/client_spec.rb +13 -16
- data/spec/elastic/transport/meta_header_spec.rb +2 -2
- data/spec/elastic/transport/sniffer_spec.rb +0 -18
- data/spec/spec_helper.rb +4 -1
- data/test/integration/jruby_test.rb +1 -1
- data/test/integration/transport_test.rb +86 -40
- data/test/test_helper.rb +8 -5
- data/test/unit/adapters_test.rb +88 -0
- data/test/unit/transport_curb_test.rb +2 -3
- metadata +17 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aca3fc15486eeb7455f903dbaa5b6a594d4fd410f895cff6b3bf832c0dcad8b4
|
4
|
+
data.tar.gz: 4fd798b71008e3bba436434a5c98321fcd2b15934a6244908966c8b9cdd5c3e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a33a557b17fc75fbc2cd9b8fb713603b67c35097fce929ccdee0b81b76c58c05885286aeb1aeed8c72068d6c12a83b51e6dc1f9f07678d6e17f51ce962cb0af8
|
7
|
+
data.tar.gz: 5105d1a01106314206e250a105329abfb9553f6c12170bafaf8b7eb4741f5d7b9b414027919aac9df9867ee0859fbfce6b492fbc64a8335f17eebcc7fd109cf4
|
data/.github/workflows/tests.yml
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
name:
|
1
|
+
name: main tests
|
2
2
|
on:
|
3
3
|
push:
|
4
4
|
branches:
|
5
|
-
-
|
5
|
+
- main
|
6
6
|
pull_request:
|
7
7
|
branches:
|
8
|
-
-
|
8
|
+
- main
|
9
9
|
jobs:
|
10
|
-
test
|
10
|
+
test:
|
11
|
+
name: 'Main tests'
|
11
12
|
env:
|
12
13
|
TEST_ES_SERVER: http://localhost:9250
|
13
14
|
PORT: 9250
|
@@ -15,9 +16,10 @@ jobs:
|
|
15
16
|
fail-fast: false
|
16
17
|
matrix:
|
17
18
|
ruby: [ '2.7', '3.0', '3.1', '3.2', 'jruby-9.3', 'jruby-9.4' ]
|
19
|
+
es_version: ['8.4-SNAPSHOT', '8.5-SNAPSHOT', '8.6-SNAPSHOT']
|
18
20
|
runs-on: ubuntu-latest
|
19
21
|
steps:
|
20
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v2
|
21
23
|
- name: Increase system limits
|
22
24
|
run: |
|
23
25
|
sudo swapoff -a
|
@@ -26,7 +28,7 @@ jobs:
|
|
26
28
|
sudo sysctl -w vm.max_map_count=262144
|
27
29
|
- uses: elastic/elastic-github-actions/elasticsearch@master
|
28
30
|
with:
|
29
|
-
stack-version:
|
31
|
+
stack-version: ${{ matrix.es_version }}
|
30
32
|
security-enabled: false
|
31
33
|
- uses: ruby/setup-ruby@v1
|
32
34
|
with:
|
@@ -43,4 +45,42 @@ jobs:
|
|
43
45
|
run: bundle exec rake test:spec
|
44
46
|
- name: integration tests
|
45
47
|
run: bundle exec rake test:integration
|
46
|
-
|
48
|
+
test-faraday1:
|
49
|
+
name: 'Test Faraday 1'
|
50
|
+
env:
|
51
|
+
TEST_ES_SERVER: http://localhost:9250
|
52
|
+
PORT: 9250
|
53
|
+
strategy:
|
54
|
+
fail-fast: false
|
55
|
+
matrix:
|
56
|
+
ruby: [ '2.7', '3.0', '3.1', '3.2', 'jruby-9.3' ]
|
57
|
+
es_version: ['8.6-SNAPSHOT']
|
58
|
+
runs-on: ubuntu-latest
|
59
|
+
steps:
|
60
|
+
- uses: actions/checkout@v2
|
61
|
+
- name: Increase system limits
|
62
|
+
run: |
|
63
|
+
sudo swapoff -a
|
64
|
+
sudo sysctl -w vm.swappiness=1
|
65
|
+
sudo sysctl -w fs.file-max=262144
|
66
|
+
sudo sysctl -w vm.max_map_count=262144
|
67
|
+
- uses: elastic/elastic-github-actions/elasticsearch@master
|
68
|
+
with:
|
69
|
+
stack-version: ${{ matrix.es_version }}
|
70
|
+
security-enabled: false
|
71
|
+
- uses: ruby/setup-ruby@v1
|
72
|
+
with:
|
73
|
+
ruby-version: ${{ matrix.ruby }}
|
74
|
+
- name: Build and test with Rake
|
75
|
+
run: |
|
76
|
+
sudo apt-get update
|
77
|
+
sudo apt-get install libcurl4-openssl-dev
|
78
|
+
ruby -v
|
79
|
+
gem install bundler
|
80
|
+
BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle install
|
81
|
+
- name: faraday1 unit tests
|
82
|
+
run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:unit
|
83
|
+
- name: specs
|
84
|
+
run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:spec
|
85
|
+
- name: integration tests
|
86
|
+
run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:integration
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,11 @@
|
|
1
|
-
## 8.
|
1
|
+
## 8.2.0
|
2
2
|
|
3
|
-
|
3
|
+
Tested versions of Ruby: (MRI) 2.7, 3.0, 3.1, 3.2, JRuby 9.3 and JRuby 9.4.
|
4
4
|
|
5
|
-
- Fixes
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Backports the following updates from 8.2:
|
10
|
-
|
11
|
-
- Refactors `apply_headers` in base and manticore implementation: When passing in an object to the initializer, `apply_headers` would mutate this object and in certain conditions, this would raise `RuntimeError` in JRuby 9.3 and `ConcurrencyError` in JRuby 9.4. This update clones the options object instead.
|
12
|
-
- Fixes [issue #44](https://github.com/elastic/elastic-transport-ruby/issues/44), raising `Elastic::Transport::Transport::Error` instead of `Faraday::ConnectionFailed` (or any other Faraday error class) when a host is unreachable.
|
13
|
-
- Fixes parsing ipv4 addresses like `inet[/127.0.0.1:9200]` in sniffer, [issue #48](https://github.com/elastic/elastic-transport-ruby/issues/48). [Pull Request](https://github.com/elastic/elastic-transport-ruby/pull/49) by [@robbat2](https://github.com/robbat2), thank you!
|
5
|
+
- Fixes [issue #44](https://github.com/elastic/elastic-transport-ruby/issues/44), raising `Elasticsearch::Transport::Transport::Error` instead of `Faraday::ConnectionFailed` (or any other Faraday error class) when a host is unreachable.
|
6
|
+
- Removes development dependency on `ansi`, it hasn't been updated for years.
|
7
|
+
- Adds `rake console` task to run IRB with the Elastic transport client libraries loaded.
|
8
|
+
- General refactors, cleanup and updates in code for `base.rb` (The base class used by HTTP implementations Faraday, Manticore, Curb), `errors.rb`, `faraday.rb`, and more.
|
14
9
|
|
15
10
|
## 8.1.0
|
16
11
|
|
data/Gemfile
CHANGED
@@ -20,15 +20,11 @@ source 'https://rubygems.org'
|
|
20
20
|
# Specify your gem's dependencies in elasticsearch-transport.gemspec
|
21
21
|
gemspec
|
22
22
|
|
23
|
-
if File.exist? File.expand_path('../elasticsearch-api/elasticsearch-api.gemspec', __dir__)
|
24
|
-
gem 'elasticsearch-api', path: File.expand_path('../elasticsearch-api', __dir__), require: false
|
25
|
-
end
|
26
|
-
|
27
|
-
if File.exist? File.expand_path('../elasticsearch/elasticsearch.gemspec', __dir__)
|
28
|
-
gem 'elasticsearch', path: File.expand_path('../elasticsearch', __dir__), require: false
|
29
|
-
end
|
30
|
-
|
31
23
|
group :development, :test do
|
24
|
+
gem 'faraday-httpclient'
|
25
|
+
gem 'faraday-net_http_persistent'
|
26
|
+
gem 'faraday-patron' unless defined? JRUBY_VERSION
|
27
|
+
gem 'faraday-typhoeus'
|
32
28
|
gem 'rspec'
|
33
29
|
if defined?(JRUBY_VERSION)
|
34
30
|
gem 'pry-nav'
|
@@ -0,0 +1,39 @@
|
|
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
|
+
source 'https://rubygems.org'
|
19
|
+
|
20
|
+
# Usage:
|
21
|
+
#
|
22
|
+
# $ BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle install
|
23
|
+
# $ BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:unit
|
24
|
+
|
25
|
+
gem 'faraday', '~> 1'
|
26
|
+
gemspec path: './'
|
27
|
+
|
28
|
+
group :development, :test do
|
29
|
+
gem 'httpclient'
|
30
|
+
gem 'net-http-persistent'
|
31
|
+
gem 'patron' unless defined? JRUBY_VERSION
|
32
|
+
gem 'rspec'
|
33
|
+
gem 'typhoeus'
|
34
|
+
if defined?(JRUBY_VERSION)
|
35
|
+
gem 'pry-nav'
|
36
|
+
else
|
37
|
+
gem 'pry-byebug'
|
38
|
+
end
|
39
|
+
end
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ response = client.perform_request('GET', '_cluster/health')
|
|
15
15
|
|
16
16
|
**Refer to [the official documentation on Elastic Transport](https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/transport.html).**
|
17
17
|
|
18
|
-
**Refer to [Advanced Configuration](https://
|
18
|
+
**Refer to [Advanced Configuration](https://elasticsearch-ruby_1881.docs-preview.app.elstc.co/guide/en/elasticsearch/client/ruby-api/master/advanced-config.html) to read about more configuration options.**
|
19
19
|
|
20
20
|
## Compatibility
|
21
21
|
|
data/Rakefile
CHANGED
@@ -18,13 +18,22 @@
|
|
18
18
|
require 'bundler/gem_tasks'
|
19
19
|
require 'mkmf'
|
20
20
|
|
21
|
-
desc
|
21
|
+
desc 'Run unit tests'
|
22
22
|
task default: 'test:unit'
|
23
23
|
task test: 'test:unit'
|
24
24
|
|
25
25
|
# ----- Test tasks ------------------------------------------------------------
|
26
26
|
require 'rake/testtask'
|
27
27
|
require 'rspec/core/rake_task'
|
28
|
+
FARADAY1_GEMFILE = 'Gemfile-faraday1.gemfile'.freeze
|
29
|
+
GEMFILES = ['Gemfile', FARADAY1_GEMFILE].freeze
|
30
|
+
|
31
|
+
task :install do
|
32
|
+
GEMFILES.each do |gemfile|
|
33
|
+
gemfile = File.expand_path("../#{gemfile}", __FILE__)
|
34
|
+
sh "bundle install --gemfile #{gemfile}"
|
35
|
+
end
|
36
|
+
end
|
28
37
|
|
29
38
|
namespace :test do
|
30
39
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -46,6 +55,7 @@ namespace :test do
|
|
46
55
|
desc 'Run all tests'
|
47
56
|
task :all do
|
48
57
|
Rake::Task['test:unit'].invoke
|
58
|
+
Rake::Task['test:spec'].invoke
|
49
59
|
Rake::Task['test:integration'].invoke
|
50
60
|
end
|
51
61
|
|
@@ -53,6 +63,34 @@ namespace :test do
|
|
53
63
|
test.libs << 'lib' << 'test'
|
54
64
|
test.test_files = FileList['test/profile/**/*_test.rb']
|
55
65
|
end
|
66
|
+
|
67
|
+
namespace :faraday1 do
|
68
|
+
desc 'Faraday 1: Run RSpec with dependency on Faraday 1'
|
69
|
+
task :spec do
|
70
|
+
sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} bundle exec rspec"
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'Faraday 1: Run unit tests with dependency on Faraday 1'
|
74
|
+
task :unit do
|
75
|
+
Dir.glob('./test/unit/**/**.rb').each do |test|
|
76
|
+
sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} ruby -Ilib:test #{test}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
desc 'Faraday 1: Run integration tests with dependency on Faraday 1'
|
81
|
+
task :integration do
|
82
|
+
Dir.glob('./test/integration/**/**.rb').each do |test|
|
83
|
+
sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} ruby -Ilib:test #{test}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'Faraday 1: Run all tests'
|
88
|
+
task :all do
|
89
|
+
Rake::Task['test:faraday1:unit'].invoke
|
90
|
+
Rake::Task['test:faraday1:spec'].invoke
|
91
|
+
Rake::Task['test:faraday1:integration'].invoke
|
92
|
+
end
|
93
|
+
end
|
56
94
|
end
|
57
95
|
|
58
96
|
namespace :docker do
|
@@ -72,6 +110,15 @@ namespace :docker do
|
|
72
110
|
end
|
73
111
|
end
|
74
112
|
|
113
|
+
desc 'Run Ruby console with the Elastic transport client libraries loaded'
|
114
|
+
task :console do
|
115
|
+
require 'irb'
|
116
|
+
require 'irb/completion'
|
117
|
+
require 'elastic-transport'
|
118
|
+
ARGV.clear
|
119
|
+
IRB.start
|
120
|
+
end
|
121
|
+
|
75
122
|
# ----- Documentation tasks ---------------------------------------------------
|
76
123
|
require 'yard'
|
77
124
|
YARD::Rake::YardocTask.new(:doc) do |t|
|
data/elastic-transport.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.name = "elastic-transport"
|
25
25
|
s.version = Elastic::Transport::VERSION
|
26
26
|
s.authors = ['Karel Minarik', 'Emily Stolfo', 'Fernando Briano']
|
27
|
-
s.email = ['
|
27
|
+
s.email = ['support@elastic.co']
|
28
28
|
s.summary = 'Low level Ruby client for Elastic services.'
|
29
29
|
s.homepage = 'https://github.com/elastic/elastic-transport-ruby'
|
30
30
|
s.license = 'Apache-2.0'
|
@@ -44,20 +44,18 @@ Gem::Specification.new do |s|
|
|
44
44
|
|
45
45
|
s.required_ruby_version = '>= 2.5'
|
46
46
|
|
47
|
+
s.add_dependency 'faraday', '< 3'
|
47
48
|
s.add_dependency 'multi_json'
|
48
|
-
s.add_dependency 'faraday', '~> 1'
|
49
49
|
|
50
|
+
# Faraday Adapters
|
51
|
+
s.add_development_dependency 'manticore' if defined? JRUBY_VERSION
|
52
|
+
s.add_development_dependency 'curb' unless defined? JRUBY_VERSION
|
50
53
|
s.add_development_dependency 'bundler'
|
51
54
|
s.add_development_dependency 'cane'
|
52
|
-
s.add_development_dependency 'curb' unless defined? JRUBY_VERSION
|
53
55
|
s.add_development_dependency 'hashie'
|
54
|
-
s.add_development_dependency 'httpclient'
|
55
|
-
s.add_development_dependency 'manticore' if defined? JRUBY_VERSION
|
56
56
|
s.add_development_dependency 'minitest'
|
57
57
|
s.add_development_dependency 'minitest-reporters'
|
58
58
|
s.add_development_dependency 'mocha'
|
59
|
-
s.add_development_dependency 'net-http-persistent'
|
60
|
-
s.add_development_dependency 'patron' unless defined? JRUBY_VERSION
|
61
59
|
s.add_development_dependency 'pry'
|
62
60
|
s.add_development_dependency 'rake', '~> 13'
|
63
61
|
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
@@ -65,7 +63,6 @@ Gem::Specification.new do |s|
|
|
65
63
|
s.add_development_dependency 'shoulda-context'
|
66
64
|
s.add_development_dependency 'simplecov'
|
67
65
|
s.add_development_dependency 'test-unit', '~> 2'
|
68
|
-
s.add_development_dependency 'typhoeus', '~> 1.4'
|
69
66
|
s.add_development_dependency 'yard'
|
70
67
|
|
71
68
|
s.description = <<-DESC.gsub(/^ /, '')
|
@@ -283,24 +283,26 @@ module Elastic
|
|
283
283
|
# Auto-detect the best adapter (HTTP "driver") available, based on libraries
|
284
284
|
# loaded by the user, preferring those with persistent connections
|
285
285
|
# ("keep-alive") by default
|
286
|
+
# Check adapters based on the usage of Faraday 1 or 2. Faraday should be defined here
|
287
|
+
# since this is only called when transport class is Transport::HTTP::Faraday
|
286
288
|
#
|
287
289
|
# @return [Symbol]
|
288
290
|
#
|
289
291
|
# @api private
|
290
292
|
#
|
291
293
|
def __auto_detect_adapter
|
292
|
-
|
293
|
-
|
294
|
-
:
|
295
|
-
|
296
|
-
:
|
297
|
-
when defined?(::HTTPClient)
|
298
|
-
:httpclient
|
299
|
-
when defined?(::Net::HTTP::Persistent)
|
300
|
-
:net_http_persistent
|
294
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new(2)
|
295
|
+
return :patron if defined?(Faraday::Adapter::Patron)
|
296
|
+
return :typhoeus if defined?(Faraday::Adapter::Typhoeus)
|
297
|
+
return :httpclient if defined?(Faraday::Adapter::HTTPClient)
|
298
|
+
return :net_http_persistent if defined?(Faraday::Adapter::NetHttpPersistent)
|
301
299
|
else
|
302
|
-
::
|
300
|
+
return :patron if defined?(::Patron)
|
301
|
+
return :typhoeus if defined?(::Typhoeus)
|
302
|
+
return :httpclient if defined?(::HTTPClient)
|
303
|
+
return :net_http_persistent if defined?(::Net::HTTP::Persistent)
|
303
304
|
end
|
305
|
+
::Faraday.default_adapter
|
304
306
|
end
|
305
307
|
end
|
306
308
|
end
|
@@ -103,31 +103,31 @@ module Elastic
|
|
103
103
|
adapter_version = case @arguments[:adapter]
|
104
104
|
when :patron
|
105
105
|
version = Patron::VERSION if defined?(::Patron::VERSION)
|
106
|
-
{pt: version}
|
106
|
+
{ pt: version }
|
107
107
|
when :net_http
|
108
108
|
version = if defined?(Net::HTTP::VERSION)
|
109
109
|
Net::HTTP::VERSION
|
110
110
|
elsif defined?(Net::HTTP::HTTPVersion)
|
111
111
|
Net::HTTP::HTTPVersion
|
112
112
|
end
|
113
|
-
{nh: version}
|
113
|
+
{ nh: version }
|
114
114
|
when :typhoeus
|
115
115
|
version = Typhoeus::VERSION if defined?(::Typhoeus::VERSION)
|
116
|
-
{ty: version}
|
116
|
+
{ ty: version }
|
117
117
|
when :httpclient
|
118
118
|
version = HTTPClient::VERSION if defined?(HTTPClient::VERSION)
|
119
|
-
{hc: version}
|
119
|
+
{ hc: version }
|
120
120
|
when :net_http_persistent
|
121
121
|
version = Net::HTTP::Persistent::VERSION if defined?(Net::HTTP::Persistent::VERSION)
|
122
|
-
{np: version}
|
122
|
+
{ np: version }
|
123
123
|
else
|
124
124
|
{}
|
125
125
|
end
|
126
|
-
{fd: Faraday::VERSION}.merge(adapter_version)
|
126
|
+
{ fd: Faraday::VERSION }.merge(adapter_version)
|
127
127
|
elsif defined?(Transport::HTTP::Curb) && @transport_class == Transport::HTTP::Curb
|
128
|
-
{cl: Curl::CURB_VERSION}
|
128
|
+
{ cl: Curl::CURB_VERSION }
|
129
129
|
elsif defined?(Transport::HTTP::Manticore) && @transport_class == Transport::HTTP::Manticore
|
130
|
-
{mc: Manticore::VERSION}
|
130
|
+
{ mc: Manticore::VERSION }
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|