elastic-transport 8.2.0 → 8.2.2

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: aca3fc15486eeb7455f903dbaa5b6a594d4fd410f895cff6b3bf832c0dcad8b4
4
- data.tar.gz: 4fd798b71008e3bba436434a5c98321fcd2b15934a6244908966c8b9cdd5c3e0
3
+ metadata.gz: 2ed8622f822c6b3d845e86e457a6391c1fac329c61e4d2e72fa6fd4a96eed269
4
+ data.tar.gz: 94866083c749a687fa5f5f8f25c076cc4823abc2e0afa318fd05cec6afb6de0b
5
5
  SHA512:
6
- metadata.gz: a33a557b17fc75fbc2cd9b8fb713603b67c35097fce929ccdee0b81b76c58c05885286aeb1aeed8c72068d6c12a83b51e6dc1f9f07678d6e17f51ce962cb0af8
7
- data.tar.gz: 5105d1a01106314206e250a105329abfb9553f6c12170bafaf8b7eb4741f5d7b9b414027919aac9df9867ee0859fbfce6b492fbc64a8335f17eebcc7fd109cf4
6
+ metadata.gz: cd88c9f775083a059f924ab8f4668d4f01fdff475dfa904743533aec4f48d7fbb4b2bbdad596fd295c43e7cbb5195ba4bec3e4daa9bcb6a1b33fd4d60bbfd324
7
+ data.tar.gz: 3c01c3ad96f481054441fe406c1680cd4c147ccb2bdedc1d46c5ad7adbdfa08fa37dda52647b4b025dc48cde54d21312eb026dfe656fdea893008f8eb85b146e
@@ -15,8 +15,8 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
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
+ ruby: [ '3.0', '3.1', '3.2', 'jruby-9.3', 'jruby-9.4' ]
19
+ es_version: ['8.7-SNAPSHOT', '8.8-SNAPSHOT', '8.9-SNAPSHOT']
20
20
  runs-on: ubuntu-latest
21
21
  steps:
22
22
  - uses: actions/checkout@v2
@@ -53,8 +53,8 @@ jobs:
53
53
  strategy:
54
54
  fail-fast: false
55
55
  matrix:
56
- ruby: [ '2.7', '3.0', '3.1', '3.2', 'jruby-9.3' ]
57
- es_version: ['8.6-SNAPSHOT']
56
+ ruby: [ '3.0', '3.1', '3.2', 'jruby-9.3' ]
57
+ es_version: ['8.9-SNAPSHOT']
58
58
  runs-on: ubuntu-latest
59
59
  steps:
60
60
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,8 +1,20 @@
1
+ ## 8.2.2
2
+
3
+ Tested versions of Ruby: (MRI) 3.0, 3.1, 3.2, JRuby 9.3 and JRuby 9.4
4
+
5
+ - 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.
6
+
7
+ ## 8.2.1
8
+
9
+ Tested versions of Ruby: (MRI) 2.7, 3.0, 3.1, 3.2, JRuby 9.3 and JRuby 9.4. Ruby 2.7's end of life is coming in a few days, so this'll probably be the last release to test for Ruby 2.7.
10
+
11
+ - 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!
12
+
1
13
  ## 8.2.0
2
14
 
3
15
  Tested versions of Ruby: (MRI) 2.7, 3.0, 3.1, 3.2, JRuby 9.3 and JRuby 9.4.
4
16
 
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.
17
+ - 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.
6
18
  - Removes development dependency on `ansi`, it hasn't been updated for years.
7
19
  - Adds `rake console` task to run IRB with the Elastic transport client libraries loaded.
8
20
  - 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.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,58 @@
1
+ # Contributing to Elasticsearch Transport Ruby
2
+
3
+
4
+ This guide assumes Ruby is already installed. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). So we can't guarantee the code works for versions of Ruby that have reached their end of life.
5
+
6
+ To work on the code, clone the project first:
7
+
8
+ ```
9
+ $ git clone git@github.com:elastic/elastic-transport-ruby.git
10
+ ```
11
+
12
+ And run `bundle install` to install dependencies.
13
+
14
+ # Tests
15
+
16
+ There are several test tasks in the Rakefile, you can check them with `rake -T` from the project's root directory.
17
+
18
+ ```bash
19
+ rake test:unit
20
+ rake test:spec
21
+ rake test:integration
22
+ ```
23
+
24
+ Use `COVERAGE=true` before running a test task to check coverage with Simplecov.
25
+
26
+ Github's pull requests and issues are used to communicate, send bug reports and code contributions. Bug fixes and features must be covered by unit tests.
27
+
28
+ You need an Elasticsearch cluster running for integration tests. The tests will use the default host `localhost:9200`, but you can change this value by setting the environment variables `TEST_ES_SERVER` or `ELASTICSEARCH_HOSTS`:
29
+
30
+ ```
31
+ $ TEST_ES_SERVER=host:port rake test:integration
32
+ ```
33
+
34
+ A rake task is included to launch an Elasticsearch cluster with Docker. You need to install docker on your system and then run:
35
+ ```bash
36
+ $ rake docker:start[VERSION]
37
+ ```
38
+
39
+ E.g.:
40
+ ```bash
41
+ $ rake docker:start[8.0.0-alpha1]
42
+ ```
43
+
44
+ You can find the available version in [Docker @ Elastic](https://www.docker.elastic.co/r/elasticsearch).
45
+
46
+ # Contributing
47
+
48
+ The process for contributing is:
49
+
50
+ 1. It is best to do your work in a separate Git branch. This makes it easier to synchronise your changes with [`rebase`](http://mislav.uniqpath.com/2013/02/merge-vs-rebase/).
51
+
52
+ 2. Make sure your changes don't break any existing tests, and that you add tests for both bugfixes and new functionality.
53
+
54
+ 3. **Sign the contributor license agreement.**
55
+ Please make sure you have signed the [Contributor License Agreement](https://www.elastic.co/contributor-agreement/). We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once.
56
+
57
+ 4. Submit a pull request.
58
+ Push your local changes to your forked copy of the repository and submit a pull request. In the pull request, describe what your changes do and mention the number of the issue where discussion has taken place, eg “Closes #123″.
data/README.md CHANGED
@@ -23,32 +23,7 @@ This gem is compatible with maintained Ruby versions. See [Ruby Maintenance Bran
23
23
 
24
24
  ## Development and Community
25
25
 
26
- For local development, clone the repository and run `bundle install`. See `rake -T` for a list of available Rake tasks for running tests, generating documentation, starting a testing cluster, etc.
27
-
28
- Bug fixes and features must be covered by unit tests.
29
-
30
- A rake task is included to launch an Elasticsearch cluster with Docker. You need to install docker on your system and then run:
31
- ```bash
32
- $ rake docker:start[VERSION]
33
- ```
34
-
35
- E.g.:
36
- ```bash
37
- $ rake docker:start[8.0.0-alpha1]
38
- ```
39
-
40
- You can find the available version in [Docker @ Elastic](https://www.docker.elastic.co/r/elasticsearch).
41
-
42
- To run tests, launch a testing cluster and use the Rake tasks:
43
-
44
- ```bash
45
- time rake test:unit
46
- time rake test:integration
47
- ```
48
-
49
- Use `COVERAGE=true` before running a test task to check coverage with Simplecov.
50
-
51
- Github's pull requests and issues are used to communicate, send bug reports and code contributions.
26
+ See [CONTRIBUTING](./CONTRIBUTING.md).
52
27
 
53
28
  ## License
54
29
 
@@ -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 = ['support@elastic.co']
27
+ s.email = ['clients-team@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'
@@ -122,8 +122,7 @@ module Elastic
122
122
  # @yield [faraday] Access and configure the `Faraday::Connection` instance directly with a block
123
123
  #
124
124
  def initialize(arguments = {}, &block)
125
- @options = arguments.transform_keys(&:to_sym)
126
- @arguments = @options
125
+ @arguments = arguments.transform_keys(&:to_sym)
127
126
  @arguments[:logger] ||= @arguments[:log] ? DEFAULT_LOGGER.call() : nil
128
127
  @arguments[:tracer] ||= @arguments[:trace] ? DEFAULT_TRACER.call() : nil
129
128
  @arguments[:reload_connections] ||= false
@@ -134,7 +133,6 @@ module Elastic
134
133
  @arguments[:transport_options] ||= {}
135
134
  @arguments[:http] ||= {}
136
135
  @arguments[:enable_meta_header] = arguments.fetch(:enable_meta_header, true)
137
- @options[:http] ||= {}
138
136
 
139
137
  @hosts ||= __extract_hosts(@arguments[:hosts] ||
140
138
  @arguments[:host] ||
@@ -236,7 +234,7 @@ module Elastic
236
234
  end
237
235
 
238
236
  host_list = hosts.map { |host| __parse_host(host) }
239
- @options[:randomize_hosts] ? host_list.shuffle! : host_list
237
+ @arguments[:randomize_hosts] ? host_list.shuffle! : host_list
240
238
  end
241
239
 
242
240
  def __parse_host(host)
@@ -273,8 +271,8 @@ module Elastic
273
271
  raise ArgumentError, "Please pass host as a String, URI or Hash -- #{host.class} given."
274
272
  end
275
273
 
276
- @options[:http][:user] ||= host_parts[:user]
277
- @options[:http][:password] ||= host_parts[:password]
274
+ @arguments[:http][:user] ||= host_parts[:user]
275
+ @arguments[:http][:password] ||= host_parts[:password]
278
276
  host_parts[:port] = host_parts[:port].to_i if host_parts[:port]
279
277
  host_parts[:path].chomp!('/') if host_parts[:path]
280
278
  host_parts
@@ -431,7 +431,7 @@ module Elastic
431
431
  end
432
432
 
433
433
  def apply_headers(client, options)
434
- headers = options[:headers] || {}
434
+ headers = options[:headers].clone || {}
435
435
  headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
436
436
  headers[USER_AGENT_STR] = find_value(headers, USER_AGENT_REGEX) || user_agent_header(client)
437
437
  client.headers[ACCEPT_ENCODING] = GZIP if use_compression?
@@ -162,7 +162,7 @@ module Elastic
162
162
  private
163
163
 
164
164
  def apply_headers(options)
165
- headers = options[:headers] || options.dig(:transport_options, :headers) || {}
165
+ headers = options[:headers].clone || options.dig(:transport_options, :headers).clone || {}
166
166
  headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
167
167
  headers[USER_AGENT_STR] = find_value(headers, USER_AGENT_REGEX) || find_value(@request_options[:headers], USER_AGENT_REGEX) || user_agent_header
168
168
  headers[ACCEPT_ENCODING] = GZIP if use_compression?
@@ -76,7 +76,9 @@ module Elastic
76
76
  end
77
77
 
78
78
  def parse_publish_address(publish_address)
79
- # publish_address is in the format hostname/ip:port
79
+ # When publish_address is in the format 'inet[hostname/ip:port]'
80
+ return parse_address_port(publish_address[6..-2]) if publish_address =~ /^inet\[.*\]$/
81
+
80
82
  if publish_address =~ /\//
81
83
  parts = publish_address.partition('/')
82
84
  [ parts[0], parse_address_port(parts[2])[1] ]
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elastic
19
19
  module Transport
20
- VERSION = '8.2.0'.freeze
20
+ VERSION = '8.2.2'.freeze
21
21
  end
22
22
  end
@@ -257,6 +257,24 @@ describe Elastic::Transport::Transport::Sniffer do
257
257
  end
258
258
  end
259
259
 
260
+ context 'when the address is IPv4' do
261
+ let(:publish_address) do
262
+ 'inet[/127.0.0.1:9200]'
263
+ end
264
+
265
+ it 'parses the response' do
266
+ expect(hosts.size).to eq(1)
267
+ end
268
+
269
+ it 'correctly parses the host' do
270
+ expect(hosts[0][:host]).to eq('127.0.0.1')
271
+ end
272
+
273
+ it 'correctly parses the port' do
274
+ expect(hosts[0][:port]).to eq('9200')
275
+ end
276
+ end
277
+
260
278
  context 'when the transport has :randomize_hosts option' do
261
279
  let(:raw_response) do
262
280
  { 'nodes' => { 'n1' => { 'http' => { 'publish_address' => '127.0.0.1:9250' } },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 8.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-01-30 00:00:00.000000000 Z
13
+ date: 2023-07-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -255,7 +255,7 @@ description: 'Low level Ruby client for Elastic. See the `elasticsearch` or `ela
255
255
 
256
256
  '
257
257
  email:
258
- - support@elastic.co
258
+ - clients-team@elastic.co
259
259
  executables: []
260
260
  extensions: []
261
261
  extra_rdoc_files:
@@ -268,6 +268,7 @@ files:
268
268
  - ".github/workflows/tests.yml"
269
269
  - ".gitignore"
270
270
  - CHANGELOG.md
271
+ - CONTRIBUTING.md
271
272
  - Gemfile
272
273
  - Gemfile-faraday1.gemfile
273
274
  - LICENSE
@@ -338,7 +339,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
339
  - !ruby/object:Gem::Version
339
340
  version: '0'
340
341
  requirements: []
341
- rubygems_version: 3.3.7
342
+ rubygems_version: 3.4.13
342
343
  signing_key:
343
344
  specification_version: 4
344
345
  summary: Low level Ruby client for Elastic services.