elastic-transport 8.1.3 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0528484d88479954777f01b3d005be41608713eeda4eb757f223b37dcf4de63
4
- data.tar.gz: 0351a6d3a75eb9b0df9899a177a26f92666df9422acca5d0b87fb63f87cd625a
3
+ metadata.gz: aca3fc15486eeb7455f903dbaa5b6a594d4fd410f895cff6b3bf832c0dcad8b4
4
+ data.tar.gz: 4fd798b71008e3bba436434a5c98321fcd2b15934a6244908966c8b9cdd5c3e0
5
5
  SHA512:
6
- metadata.gz: 29f63fc511e913532c87e2ff56db0fd2af466ddc07aac40345e4130691d93e6823f4450ed9cb6b1d50c12a41183a2c9e12f6678129541ef8408cd5894bac544c
7
- data.tar.gz: d8c965dfb93c49ce3b44ed802b82e853d1a6049d49b0b3e3426cd2f6ce9e37385bf1536212ec024159d6efdd25f60b58a90afe864972e7c0a4247c5a075b372a
6
+ metadata.gz: a33a557b17fc75fbc2cd9b8fb713603b67c35097fce929ccdee0b81b76c58c05885286aeb1aeed8c72068d6c12a83b51e6dc1f9f07678d6e17f51ce962cb0af8
7
+ data.tar.gz: 5105d1a01106314206e250a105329abfb9553f6c12170bafaf8b7eb4741f5d7b9b414027919aac9df9867ee0859fbfce6b492fbc64a8335f17eebcc7fd109cf4
@@ -4,7 +4,7 @@ jobs:
4
4
  build:
5
5
  runs-on: ubuntu-latest
6
6
  steps:
7
- - uses: actions/checkout@v3
7
+ - uses: actions/checkout@v2
8
8
  - uses: ruby/setup-ruby@v1
9
9
  with:
10
10
  ruby-version: 3
@@ -1,23 +1,25 @@
1
- name: 8.1 tests
1
+ name: main tests
2
2
  on:
3
3
  push:
4
4
  branches:
5
- - 8.1
5
+ - main
6
6
  pull_request:
7
7
  branches:
8
- - 8.1
8
+ - main
9
9
  jobs:
10
- test-ruby:
10
+ test:
11
+ name: 'Main tests'
11
12
  env:
12
13
  TEST_ES_SERVER: http://localhost:9250
13
14
  PORT: 9250
14
15
  strategy:
15
16
  fail-fast: false
16
17
  matrix:
17
- ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3', 'jruby-9.3', 'jruby-9.4' ]
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@v3
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: 8.12-SNAPSHOT
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
@@ -5,7 +5,7 @@
5
5
  .bundle
6
6
  .config
7
7
  .yardoc
8
- Gemfile.lock
8
+ Gemfile*.lock
9
9
  InstalledFiles
10
10
  _yardoc
11
11
  coverage
data/CHANGELOG.md CHANGED
@@ -1,22 +1,11 @@
1
- ## 8.1.3
1
+ ## 8.2.0
2
2
 
3
- Tested versions of Ruby: (MRI) 2.7, 3.0, 3.1, 3.2, 3.3, JRuby 9.3 and JRuby 9.4
3
+ Tested versions of Ruby: (MRI) 2.7, 3.0, 3.1, 3.2, JRuby 9.3 and JRuby 9.4.
4
4
 
5
- - Removes unneccessary `require 'base64'` found thanks to warning in Ruby 3.3. So this removes the warning too if you were using Ruby 3.3.
6
-
7
- ## 8.1.2
8
-
9
- Backports the following fix from 8.2:
10
-
11
- - Fixes enforcing UTF-8 in Response body, causing an error when the string is frozen, particularly when using webmock. [issue #63](https://github.com/elastic/elastic-transport-ruby/issues/63)
12
-
13
- ## 8.1.1
14
-
15
- Backports the following updates from 8.2:
16
-
17
- - 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.
18
- - 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.
19
- - 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.
20
9
 
21
10
  ## 8.1.0
22
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://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/advanced-config.html) to read about more configuration options.**
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 "Run unit tests"
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|
@@ -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 = ['clients-team@elastic.co']
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(/^ /, '')
@@ -15,6 +15,7 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
+ require 'base64'
18
19
  require 'elastic/transport/meta_header'
19
20
 
20
21
  module Elastic
@@ -282,24 +283,26 @@ module Elastic
282
283
  # Auto-detect the best adapter (HTTP "driver") available, based on libraries
283
284
  # loaded by the user, preferring those with persistent connections
284
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
285
288
  #
286
289
  # @return [Symbol]
287
290
  #
288
291
  # @api private
289
292
  #
290
293
  def __auto_detect_adapter
291
- case
292
- when defined?(::Patron)
293
- :patron
294
- when defined?(::Typhoeus)
295
- :typhoeus
296
- when defined?(::HTTPClient)
297
- :httpclient
298
- when defined?(::Net::HTTP::Persistent)
299
- :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)
300
299
  else
301
- ::Faraday.default_adapter
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)
302
304
  end
305
+ ::Faraday.default_adapter
303
306
  end
304
307
  end
305
308
  end
@@ -15,6 +15,8 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
+ require 'base64'
19
+
18
20
  module Elastic
19
21
  module Transport
20
22
  # Methods for the Elastic meta header used by Cloud.
@@ -101,31 +103,31 @@ module Elastic
101
103
  adapter_version = case @arguments[:adapter]
102
104
  when :patron
103
105
  version = Patron::VERSION if defined?(::Patron::VERSION)
104
- {pt: version}
106
+ { pt: version }
105
107
  when :net_http
106
108
  version = if defined?(Net::HTTP::VERSION)
107
109
  Net::HTTP::VERSION
108
110
  elsif defined?(Net::HTTP::HTTPVersion)
109
111
  Net::HTTP::HTTPVersion
110
112
  end
111
- {nh: version}
113
+ { nh: version }
112
114
  when :typhoeus
113
115
  version = Typhoeus::VERSION if defined?(::Typhoeus::VERSION)
114
- {ty: version}
116
+ { ty: version }
115
117
  when :httpclient
116
118
  version = HTTPClient::VERSION if defined?(HTTPClient::VERSION)
117
- {hc: version}
119
+ { hc: version }
118
120
  when :net_http_persistent
119
121
  version = Net::HTTP::Persistent::VERSION if defined?(Net::HTTP::Persistent::VERSION)
120
- {np: version}
122
+ { np: version }
121
123
  else
122
124
  {}
123
125
  end
124
- {fd: Faraday::VERSION}.merge(adapter_version)
126
+ { fd: Faraday::VERSION }.merge(adapter_version)
125
127
  elsif defined?(Transport::HTTP::Curb) && @transport_class == Transport::HTTP::Curb
126
- {cl: Curl::CURB_VERSION}
128
+ { cl: Curl::CURB_VERSION }
127
129
  elsif defined?(Transport::HTTP::Manticore) && @transport_class == Transport::HTTP::Manticore
128
- {mc: Manticore::VERSION}
130
+ { mc: Manticore::VERSION }
129
131
  end
130
132
  end
131
133
  end