search_flip 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +4 -1
- data/lib/search_flip/http_client.rb +26 -5
- data/lib/search_flip/version.rb +1 -1
- data/spec/search_flip/http_client_spec.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6722b210d8b3d0baa98e3370f26e2f293a21ea7db15dd08ba47deb2a1dba4e1c
|
4
|
+
data.tar.gz: a66d9f5482e06ae11cffeece148a8eb290523ee6ec4c91f510c1258b1c780225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e60dbae8d1bf0c4be3964bd0daf0740c4dd89827d61481d21960af17f34b237b512dde09f08111949d9b728bc3290c59a535930e168aaa562c30c9f74faa841
|
7
|
+
data.tar.gz: 3b7d941dee59924dc47b486e5cd3d88af8a3a9a42e8f6952e14934087e2a0acbe0014ee09caabec373640c35c5ae1d72a433e2100fcd2257e8d920c09f39e3b6
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -756,7 +756,7 @@ end
|
|
756
756
|
This allows to use different clusters per index e.g. when migrating indices to
|
757
757
|
new versions of Elasticsearch.
|
758
758
|
|
759
|
-
You can specify basic auth, additional headers, etc via:
|
759
|
+
You can specify basic auth, additional headers, request timeouts, etc via:
|
760
760
|
|
761
761
|
```ruby
|
762
762
|
http_client = SearchFlip::HTTPClient.new
|
@@ -773,6 +773,9 @@ http_client = http_client.via("proxy.host", 8080)
|
|
773
773
|
# Custom headers
|
774
774
|
http_client = http_client.headers(key: "value")
|
775
775
|
|
776
|
+
# Timeouts
|
777
|
+
http_client = http_client.timeout(20)
|
778
|
+
|
776
779
|
SearchFlip::Connection.new(base_url: "...", http_client: http_client)
|
777
780
|
```
|
778
781
|
|
@@ -1,7 +1,28 @@
|
|
1
1
|
module SearchFlip
|
2
|
-
# The SearchFlip::HTTPClient class wraps the http gem
|
3
|
-
#
|
4
|
-
# with
|
2
|
+
# The SearchFlip::HTTPClient class wraps the http gem and responsible for the
|
3
|
+
# http request/response handling, ie communicating with Elasticsearch. You
|
4
|
+
# only need to use it directly if you need authentication to communicate with
|
5
|
+
# Elasticsearch or if you want to set some custom http settings.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# http_client = SearchFlip::HTTPClient.new
|
9
|
+
#
|
10
|
+
# # Basic Auth
|
11
|
+
# http_client = http_client.basic_auth(user: "username", pass: "password")
|
12
|
+
#
|
13
|
+
# # Raw Auth Header
|
14
|
+
# http_client = http_client.auth("Bearer VGhlIEhUVFAgR2VtLCBST0NLUw")
|
15
|
+
#
|
16
|
+
# # Proxy Settings
|
17
|
+
# http_client = http_client.via("proxy.host", 8080)
|
18
|
+
#
|
19
|
+
# # Custom headers
|
20
|
+
# http_client = http_client.headers(key: "value")
|
21
|
+
#
|
22
|
+
# # Timeouts
|
23
|
+
# http_client = http_client.timeout(20)
|
24
|
+
#
|
25
|
+
# SearchFlip::Connection.new(base_url: "...", http_client: http_client)
|
5
26
|
|
6
27
|
class HTTPClient
|
7
28
|
attr_accessor :request, :plugins
|
@@ -14,11 +35,11 @@ module SearchFlip
|
|
14
35
|
class << self
|
15
36
|
extend Forwardable
|
16
37
|
|
17
|
-
def_delegators :new, :headers, :via, :basic_auth, :auth
|
38
|
+
def_delegators :new, :headers, :via, :basic_auth, :auth, :timeout
|
18
39
|
def_delegators :new, :get, :post, :put, :delete, :head
|
19
40
|
end
|
20
41
|
|
21
|
-
[:headers, :via, :basic_auth, :auth].each do |method|
|
42
|
+
[:headers, :via, :basic_auth, :auth, :timeout].each do |method|
|
22
43
|
define_method method do |*args|
|
23
44
|
dup.tap do |client|
|
24
45
|
client.request = request.send(method, *args)
|
data/lib/search_flip/version.rb
CHANGED
@@ -7,7 +7,7 @@ class HttpTestRequest
|
|
7
7
|
self.calls = []
|
8
8
|
end
|
9
9
|
|
10
|
-
[:via, :basic_auth, :auth].each do |method|
|
10
|
+
[:headers, :via, :basic_auth, :auth, :timeout].each do |method|
|
11
11
|
define_method method do |*args|
|
12
12
|
dup.tap do |request|
|
13
13
|
request.calls = calls + [[method, args]]
|
@@ -20,7 +20,7 @@ RSpec.describe SearchFlip::HTTPClient do
|
|
20
20
|
describe "delegation" do
|
21
21
|
subject { SearchFlip::HTTPClient }
|
22
22
|
|
23
|
-
[:headers, :via, :basic_auth, :auth].each do |method|
|
23
|
+
[:headers, :via, :basic_auth, :auth, :timeout].each do |method|
|
24
24
|
it { should delegate(method).to(:new) }
|
25
25
|
end
|
26
26
|
|
@@ -56,8 +56,12 @@ RSpec.describe SearchFlip::HTTPClient do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
[:via, :basic_auth, :auth].each do |method|
|
59
|
+
[:headers, :via, :basic_auth, :auth, :timeout].each do |method|
|
60
60
|
describe "##{method}" do
|
61
|
+
it "is understood by HTTP" do
|
62
|
+
expect(HTTP.respond_to?(method)).to eq(true)
|
63
|
+
end
|
64
|
+
|
61
65
|
it "creates a dupped instance" do
|
62
66
|
client = SearchFlip::HTTPClient.new
|
63
67
|
client.request = HttpTestRequest.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_flip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Vetter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|