opensearch-transport 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data/.gitignore +17 -0
- data/Gemfile +47 -0
- data/LICENSE +202 -0
- data/README.md +551 -0
- data/Rakefile +89 -0
- data/lib/opensearch/transport/client.rb +354 -0
- data/lib/opensearch/transport/redacted.rb +84 -0
- data/lib/opensearch/transport/transport/base.rb +450 -0
- data/lib/opensearch/transport/transport/connections/collection.rb +136 -0
- data/lib/opensearch/transport/transport/connections/connection.rb +169 -0
- data/lib/opensearch/transport/transport/connections/selector.rb +101 -0
- data/lib/opensearch/transport/transport/errors.rb +100 -0
- data/lib/opensearch/transport/transport/http/curb.rb +140 -0
- data/lib/opensearch/transport/transport/http/faraday.rb +101 -0
- data/lib/opensearch/transport/transport/http/manticore.rb +188 -0
- data/lib/opensearch/transport/transport/loggable.rb +94 -0
- data/lib/opensearch/transport/transport/response.rb +46 -0
- data/lib/opensearch/transport/transport/serializer/multi_json.rb +62 -0
- data/lib/opensearch/transport/transport/sniffer.rb +111 -0
- data/lib/opensearch/transport/version.rb +31 -0
- data/lib/opensearch/transport.rb +46 -0
- data/lib/opensearch-transport.rb +27 -0
- data/opensearch-transport.gemspec +92 -0
- data/spec/opensearch/connections/collection_spec.rb +275 -0
- data/spec/opensearch/connections/selector_spec.rb +183 -0
- data/spec/opensearch/transport/base_spec.rb +313 -0
- data/spec/opensearch/transport/client_spec.rb +1818 -0
- data/spec/opensearch/transport/sniffer_spec.rb +284 -0
- data/spec/spec_helper.rb +99 -0
- data/test/integration/transport_test.rb +108 -0
- data/test/profile/client_benchmark_test.rb +141 -0
- data/test/test_helper.rb +97 -0
- data/test/unit/connection_test.rb +145 -0
- data/test/unit/response_test.rb +41 -0
- data/test/unit/serializer_test.rb +42 -0
- data/test/unit/transport_base_test.rb +673 -0
- data/test/unit/transport_curb_test.rb +143 -0
- data/test/unit/transport_faraday_test.rb +237 -0
- data/test/unit/transport_manticore_test.rb +191 -0
- data.tar.gz.sig +1 -0
- metadata +456 -0
- metadata.gz.sig +1 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'manticore'
|
28
|
+
|
29
|
+
module OpenSearch
|
30
|
+
module Transport
|
31
|
+
module Transport
|
32
|
+
module HTTP
|
33
|
+
# Alternative HTTP transport implementation for JRuby,
|
34
|
+
# using the [_Manticore_](https://github.com/cheald/manticore) client,
|
35
|
+
#
|
36
|
+
# @example HTTP
|
37
|
+
#
|
38
|
+
# require 'opensearch/transport/transport/http/manticore'
|
39
|
+
#
|
40
|
+
# client = OpenSearch::Client.new transport_class: OpenSearch::Transport::Transport::HTTP::Manticore
|
41
|
+
#
|
42
|
+
# client.transport.connections.first.connection
|
43
|
+
# => #<Manticore::Client:0x56bf7ca6 ...>
|
44
|
+
#
|
45
|
+
# client.info['status']
|
46
|
+
# => 200
|
47
|
+
#
|
48
|
+
# @example HTTPS (All SSL settings are optional,
|
49
|
+
# see http://www.rubydoc.info/gems/manticore/Manticore/Client:initialize)
|
50
|
+
#
|
51
|
+
# require 'opensearch/transport/transport/http/manticore'
|
52
|
+
#
|
53
|
+
# client = OpenSearch::Client.new \
|
54
|
+
# url: 'https://opensearch.example.com',
|
55
|
+
# transport_class: OpenSearch::Transport::Transport::HTTP::Manticore,
|
56
|
+
# ssl: {
|
57
|
+
# truststore: '/tmp/truststore.jks',
|
58
|
+
# truststore_password: 'password',
|
59
|
+
# keystore: '/tmp/keystore.jks',
|
60
|
+
# keystore_password: 'secret',
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
# client.transport.connections.first.connection
|
64
|
+
# => #<Manticore::Client:0xdeadbeef ...>
|
65
|
+
#
|
66
|
+
# client.info['status']
|
67
|
+
# => 200
|
68
|
+
#
|
69
|
+
# @see Transport::Base
|
70
|
+
#
|
71
|
+
class Manticore
|
72
|
+
include Base
|
73
|
+
|
74
|
+
def initialize(arguments={}, &block)
|
75
|
+
@manticore = build_client(arguments[:options] || {})
|
76
|
+
super(arguments, &block)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Should just be run once at startup
|
80
|
+
def build_client(options={})
|
81
|
+
client_options = options[:transport_options] || {}
|
82
|
+
client_options[:ssl] = options[:ssl] || {}
|
83
|
+
|
84
|
+
@manticore = ::Manticore::Client.new(client_options)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Performs the request by invoking {Transport::Base#perform_request} with a block.
|
88
|
+
#
|
89
|
+
# @return [Response]
|
90
|
+
# @see Transport::Base#perform_request
|
91
|
+
#
|
92
|
+
def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
|
93
|
+
super do |connection, url|
|
94
|
+
params[:body] = __convert_to_json(body) if body
|
95
|
+
params[:headers] = headers if headers
|
96
|
+
params = params.merge @request_options
|
97
|
+
case method
|
98
|
+
when "GET"
|
99
|
+
resp = connection.connection.get(url, params)
|
100
|
+
when "HEAD"
|
101
|
+
resp = connection.connection.head(url, params)
|
102
|
+
when "PUT"
|
103
|
+
resp = connection.connection.put(url, params)
|
104
|
+
when "POST"
|
105
|
+
resp = connection.connection.post(url, params)
|
106
|
+
when "DELETE"
|
107
|
+
resp = connection.connection.delete(url, params)
|
108
|
+
else
|
109
|
+
raise ArgumentError.new "Method #{method} not supported"
|
110
|
+
end
|
111
|
+
Response.new resp.code, resp.read_body, resp.headers
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Builds and returns a collection of connections.
|
116
|
+
# Each connection is a Manticore::Client
|
117
|
+
#
|
118
|
+
# @return [Connections::Collection]
|
119
|
+
#
|
120
|
+
def __build_connections
|
121
|
+
@request_options = {}
|
122
|
+
apply_headers(@request_options, options[:transport_options])
|
123
|
+
apply_headers(@request_options, options)
|
124
|
+
|
125
|
+
Connections::Collection.new \
|
126
|
+
:connections => hosts.map { |host|
|
127
|
+
host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL
|
128
|
+
host[:port] ||= DEFAULT_PORT
|
129
|
+
|
130
|
+
host.delete(:user) # auth is not supported here.
|
131
|
+
host.delete(:password) # use the headers
|
132
|
+
|
133
|
+
Connections::Connection.new \
|
134
|
+
:host => host,
|
135
|
+
:connection => @manticore
|
136
|
+
},
|
137
|
+
:selector_class => options[:selector_class],
|
138
|
+
:selector => options[:selector]
|
139
|
+
end
|
140
|
+
|
141
|
+
# Closes all connections by marking them as dead
|
142
|
+
# and closing the underlying HttpClient instances
|
143
|
+
#
|
144
|
+
# @return [Connections::Collection]
|
145
|
+
#
|
146
|
+
def __close_connections
|
147
|
+
# The Manticore adapter uses a single long-lived instance
|
148
|
+
# of Manticore::Client, so we don't close the connections.
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns an array of implementation specific connection errors.
|
152
|
+
#
|
153
|
+
# @return [Array]
|
154
|
+
#
|
155
|
+
def host_unreachable_exceptions
|
156
|
+
[
|
157
|
+
::Manticore::Timeout,
|
158
|
+
::Manticore::SocketException,
|
159
|
+
::Manticore::ClientProtocolException,
|
160
|
+
::Manticore::ResolutionFailure
|
161
|
+
]
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
def apply_headers(request_options, options)
|
167
|
+
headers = (options && options[:headers]) || {}
|
168
|
+
headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
|
169
|
+
headers[USER_AGENT_STR] = find_value(headers, USER_AGENT_REGEX) || user_agent_header
|
170
|
+
headers[ACCEPT_ENCODING] = GZIP if use_compression?
|
171
|
+
request_options.merge!(headers: headers)
|
172
|
+
end
|
173
|
+
|
174
|
+
def user_agent_header
|
175
|
+
@user_agent ||= begin
|
176
|
+
meta = ["RUBY_VERSION: #{JRUBY_VERSION}"]
|
177
|
+
if RbConfig::CONFIG && RbConfig::CONFIG['host_os']
|
178
|
+
meta << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}"
|
179
|
+
end
|
180
|
+
meta << "Manticore #{::Manticore::VERSION}"
|
181
|
+
"opensearch-ruby/#{VERSION} (#{meta.join('; ')})"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
module OpenSearch
|
28
|
+
|
29
|
+
# Module to encapsulate all logging functionality.
|
30
|
+
#
|
31
|
+
# @since 7.0.0
|
32
|
+
module Loggable
|
33
|
+
|
34
|
+
# Log a debug message.
|
35
|
+
#
|
36
|
+
# @example Log a debug message.
|
37
|
+
# log_debug('Message')
|
38
|
+
#
|
39
|
+
# @param [ String ] message The message to log.
|
40
|
+
#
|
41
|
+
# @since 7.0.0
|
42
|
+
def log_debug(message)
|
43
|
+
logger.debug(message) if logger && logger.debug?
|
44
|
+
end
|
45
|
+
|
46
|
+
# Log an error message.
|
47
|
+
#
|
48
|
+
# @example Log an error message.
|
49
|
+
# log_error('Message')
|
50
|
+
#
|
51
|
+
# @param [ String ] message The message to log.
|
52
|
+
#
|
53
|
+
# @since 7.0.0
|
54
|
+
def log_error(message)
|
55
|
+
logger.error(message) if logger && logger.error?
|
56
|
+
end
|
57
|
+
|
58
|
+
# Log a fatal message.
|
59
|
+
#
|
60
|
+
# @example Log a fatal message.
|
61
|
+
# log_fatal('Message')
|
62
|
+
#
|
63
|
+
# @param [ String ] message The message to log.
|
64
|
+
#
|
65
|
+
# @since 7.0.0
|
66
|
+
def log_fatal(message)
|
67
|
+
logger.fatal(message) if logger && logger.fatal?
|
68
|
+
end
|
69
|
+
|
70
|
+
# Log an info message.
|
71
|
+
#
|
72
|
+
# @example Log an info message.
|
73
|
+
# log_info('Message')
|
74
|
+
#
|
75
|
+
# @param [ String ] message The message to log.
|
76
|
+
#
|
77
|
+
# @since 7.0.0
|
78
|
+
def log_info(message)
|
79
|
+
logger.info(message) if logger && logger.info?
|
80
|
+
end
|
81
|
+
|
82
|
+
# Log a warn message.
|
83
|
+
#
|
84
|
+
# @example Log a warn message.
|
85
|
+
# log_warn('Message')
|
86
|
+
#
|
87
|
+
# @param [ String ] message The message to log.
|
88
|
+
#
|
89
|
+
# @since 7.0.0
|
90
|
+
def log_warn(message)
|
91
|
+
logger.warn(message) if logger && logger.warn?
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
module OpenSearch
|
28
|
+
module Transport
|
29
|
+
module Transport
|
30
|
+
# Wraps the response from OpenSearch.
|
31
|
+
#
|
32
|
+
class Response
|
33
|
+
attr_reader :status, :body, :headers
|
34
|
+
|
35
|
+
# @param status [Integer] Response status code
|
36
|
+
# @param body [String] Response body
|
37
|
+
# @param headers [Hash] Response headers
|
38
|
+
def initialize(status, body, headers={})
|
39
|
+
@status, @body, @headers = status, body, headers
|
40
|
+
@body = body.force_encoding('UTF-8') if body.respond_to?(:force_encoding)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
module OpenSearch
|
28
|
+
module Transport
|
29
|
+
module Transport
|
30
|
+
module Serializer
|
31
|
+
|
32
|
+
# An abstract class for implementing serializer implementations
|
33
|
+
#
|
34
|
+
module Base
|
35
|
+
# @param transport [Object] The instance of transport which uses this serializer
|
36
|
+
#
|
37
|
+
def initialize(transport=nil)
|
38
|
+
@transport = transport
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# A default JSON serializer (using [MultiJSON](http://rubygems.org/gems/multi_json))
|
43
|
+
#
|
44
|
+
class MultiJson
|
45
|
+
include Base
|
46
|
+
|
47
|
+
# De-serialize a Hash from JSON string
|
48
|
+
#
|
49
|
+
def load(string, options={})
|
50
|
+
::MultiJson.load(string, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Serialize a Hash to JSON string
|
54
|
+
#
|
55
|
+
def dump(object, options={})
|
56
|
+
::MultiJson.dump(object, options)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
module OpenSearch
|
28
|
+
module Transport
|
29
|
+
module Transport
|
30
|
+
|
31
|
+
# Handles node discovery ("sniffing")
|
32
|
+
#
|
33
|
+
class Sniffer
|
34
|
+
PROTOCOL = 'http'
|
35
|
+
|
36
|
+
attr_reader :transport
|
37
|
+
attr_accessor :timeout
|
38
|
+
|
39
|
+
# @param transport [Object] A transport instance
|
40
|
+
#
|
41
|
+
def initialize(transport)
|
42
|
+
@transport = transport
|
43
|
+
@timeout = transport.options[:sniffer_timeout] || 1
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieves the node list from the OpenSearch's
|
47
|
+
# _Nodes Info API_
|
48
|
+
# and returns a normalized Array of information suitable for passing to transport.
|
49
|
+
#
|
50
|
+
# Shuffles the collection before returning it when the `randomize_hosts` option is set for transport.
|
51
|
+
#
|
52
|
+
# @return [Array<Hash>]
|
53
|
+
# @raise [SnifferTimeoutError]
|
54
|
+
#
|
55
|
+
def hosts
|
56
|
+
Timeout::timeout(timeout, SnifferTimeoutError) do
|
57
|
+
nodes = perform_sniff_request.body
|
58
|
+
|
59
|
+
hosts = nodes['nodes'].map do |id, info|
|
60
|
+
next unless info[PROTOCOL]
|
61
|
+
host, port = parse_publish_address(info[PROTOCOL]['publish_address'])
|
62
|
+
|
63
|
+
{
|
64
|
+
id: id,
|
65
|
+
name: info['name'],
|
66
|
+
version: info['version'],
|
67
|
+
host: host,
|
68
|
+
port: port,
|
69
|
+
roles: info['roles'],
|
70
|
+
attributes: info['attributes']
|
71
|
+
}
|
72
|
+
end.compact
|
73
|
+
|
74
|
+
hosts.shuffle! if transport.options[:randomize_hosts]
|
75
|
+
hosts
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def perform_sniff_request
|
82
|
+
transport.perform_request(
|
83
|
+
'GET', '_nodes/http', {}, nil, nil,
|
84
|
+
reload_on_failure: false
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
def parse_publish_address(publish_address)
|
89
|
+
# publish_address is in the format hostname/ip:port
|
90
|
+
if publish_address =~ /\//
|
91
|
+
parts = publish_address.partition('/')
|
92
|
+
[ parts[0], parse_address_port(parts[2])[1] ]
|
93
|
+
else
|
94
|
+
parse_address_port(publish_address)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def parse_address_port(publish_address)
|
99
|
+
# address is ipv6
|
100
|
+
if publish_address =~ /[\[\]]/
|
101
|
+
if parts = publish_address.match(/\A\[(.+)\](?::(\d+))?\z/)
|
102
|
+
[ parts[1], parts[2] ]
|
103
|
+
end
|
104
|
+
else
|
105
|
+
publish_address.split(':')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
module OpenSearch
|
28
|
+
module Transport
|
29
|
+
VERSION = '1.0.0'.freeze
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'uri'
|
28
|
+
require 'time'
|
29
|
+
require 'timeout'
|
30
|
+
require 'multi_json'
|
31
|
+
require 'faraday'
|
32
|
+
|
33
|
+
require 'opensearch/transport/transport/loggable'
|
34
|
+
require 'opensearch/transport/transport/serializer/multi_json'
|
35
|
+
require 'opensearch/transport/transport/sniffer'
|
36
|
+
require 'opensearch/transport/transport/response'
|
37
|
+
require 'opensearch/transport/transport/errors'
|
38
|
+
require 'opensearch/transport/transport/base'
|
39
|
+
require 'opensearch/transport/transport/connections/selector'
|
40
|
+
require 'opensearch/transport/transport/connections/connection'
|
41
|
+
require 'opensearch/transport/transport/connections/collection'
|
42
|
+
require 'opensearch/transport/transport/http/faraday'
|
43
|
+
require 'opensearch/transport/client'
|
44
|
+
require 'opensearch/transport/redacted'
|
45
|
+
|
46
|
+
require 'opensearch/transport/version'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'opensearch/transport'
|