barkibu-kb 0.32.0 → 1.0.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/CHANGELOG.md +9 -1
- data/Gemfile.lock +4 -27
- data/README.md +10 -1
- data/barkibu-kb.gemspec +1 -1
- data/lib/barkibu-kb.rb +3 -2
- data/lib/kb/client.rb +10 -4
- data/lib/kb/fake/api.rb +10 -0
- data/lib/kb/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5eb3a704f422c511e2e30d584cd6a80a7d91a090cfa5452dd197e65496b52eee
|
|
4
|
+
data.tar.gz: 05d766aeca3b869601193bd1a6310ced1c07f96d6f24cd5424c290a33b1edaf9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 994f4d86e1c2d1aa40a173ed0b77a2fcff39cbfe1e0390c728f92887be3817e3851610f85796c24a61919c05789a718c3939ee965866a1fda2f72ed2e68492b1
|
|
7
|
+
data.tar.gz: c9de80ede2701f7e58bde7f803b473980383d6ec9ac3d8509f2fe0e74ff15a200e48025ecc2535bc7102b82f1199228806d1e1999de32745ae07123123cb7edd
|
data/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
## [unreleased]
|
|
9
|
-
- See diff: https://github.com/barkibu/kb-ruby/compare/
|
|
9
|
+
- See diff: https://github.com/barkibu/kb-ruby/compare/v1.0.0...HEAD
|
|
10
|
+
|
|
11
|
+
## [1.0.0]
|
|
12
|
+
- [Breaking changes] Split the single global request timeout into per-phase budgets: `KB.config.request.connect_timeout` (default 1s, bounds TCP connect + TLS handshake), `write_timeout` (default 3s), `read_timeout` (default 5s). `KB.config.request.timeout` is removed — assigning it now raises `NoMethodError` at boot. Migration: a previous global `timeout` maps to `read_timeout` (e.g. `KB_REQUEST_TIMEOUT_SECONDS=12` → `read_timeout = 12`).
|
|
13
|
+
- [Breaking changes] Switch the HTTP adapter from http.rb (`faraday-http`) to Net::HTTP (`faraday-net_http`) — the stock adapter honours all three phase timeouts, aligns the KB client with the rest of our outbound HTTP, and opens a one-line upgrade path to `faraday-net_http_persistent` for connection reuse. Raw error classes change accordingly (`Net::OpenTimeout`/`Net::ReadTimeout`/`Net::WriteTimeout`/`Errno::*` instead of `HTTP::*`) — relevant to APM span queries on `error.type`.
|
|
14
|
+
- Faraday-level wrapping keeps the same three classes (`Faraday::TimeoutError`/`ConnectionFailed`/`SSLError`) with one movement between them: a connect/TLS-phase expiry now surfaces as `Faraday::ConnectionFailed` (was `Faraday::TimeoutError`), making `ConnectionFailed` cleanly mean "the request never got through the pipe".
|
|
15
|
+
- Net::HTTP's idempotent auto-retry stays disabled (`max_retries = 0`, enforced by the adapter and pinned by a spec) — no behaviour change vs. the previous no-retry client.
|
|
16
|
+
- There is no total request budget anymore; worst-case wall clock is the sum of the phase budgets rather than a single number.
|
|
17
|
+
- barkibu-kb-fake: disable Sinatra's host authorization (`set :host_authorization, permitted_hosts: []`). Sinatra >= 4.1 authorizes the Host header and, when it infers a development environment, only permits localhost-style hosts — rejecting requests to the stubbed KB host with `403 Host not permitted`. Permitting the host on the consumer side stops working with the net_http adapter, because WebMock intercepts before Net::HTTP adds the Host header, so the header is absent and can never match a permitted list. Consumers can drop their own `set :host_authorization` workarounds.
|
|
10
18
|
|
|
11
19
|
## [0.32.0]
|
|
12
20
|
- Allow Ruby 3.3/3.4: raise `required_ruby_version` ceiling to `< 3.6` (floor stays `>= 2.6`)
|
data/Gemfile.lock
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
barkibu-kb (0.
|
|
4
|
+
barkibu-kb (1.0.0)
|
|
5
5
|
activemodel (>= 4.0.2)
|
|
6
6
|
activerecord
|
|
7
7
|
activesupport (>= 3.0.0)
|
|
8
8
|
dry-configurable (~> 0.9)
|
|
9
9
|
faraday
|
|
10
|
-
faraday-
|
|
10
|
+
faraday-net_http (~> 1.0)
|
|
11
11
|
faraday_middleware
|
|
12
12
|
i18n
|
|
13
|
-
barkibu-kb-fake (0.
|
|
14
|
-
barkibu-kb (= 0.
|
|
13
|
+
barkibu-kb-fake (1.0.0)
|
|
14
|
+
barkibu-kb (= 1.0.0)
|
|
15
15
|
countries
|
|
16
16
|
sinatra
|
|
17
17
|
webmock
|
|
@@ -52,8 +52,6 @@ GEM
|
|
|
52
52
|
rexml
|
|
53
53
|
diff-lcs (1.4.4)
|
|
54
54
|
docile (1.4.0)
|
|
55
|
-
domain_name (0.5.20190701)
|
|
56
|
-
unf (>= 0.0.5, < 1.0.0)
|
|
57
55
|
drb (2.2.3)
|
|
58
56
|
dry-configurable (0.16.1)
|
|
59
57
|
dry-core (~> 0.6)
|
|
@@ -76,9 +74,6 @@ GEM
|
|
|
76
74
|
faraday-em_http (1.0.0)
|
|
77
75
|
faraday-em_synchrony (1.0.0)
|
|
78
76
|
faraday-excon (1.1.0)
|
|
79
|
-
faraday-http (1.1.0)
|
|
80
|
-
faraday (~> 1.0)
|
|
81
|
-
http (>= 4.0, < 6)
|
|
82
77
|
faraday-httpclient (1.0.1)
|
|
83
78
|
faraday-multipart (1.0.4)
|
|
84
79
|
multipart-post (~> 2)
|
|
@@ -89,25 +84,10 @@ GEM
|
|
|
89
84
|
faraday-retry (1.0.3)
|
|
90
85
|
faraday_middleware (1.2.0)
|
|
91
86
|
faraday (~> 1.0)
|
|
92
|
-
ffi (1.15.5)
|
|
93
|
-
ffi-compiler (1.0.1)
|
|
94
|
-
ffi (>= 1.0.0)
|
|
95
|
-
rake
|
|
96
87
|
hashdiff (1.0.1)
|
|
97
|
-
http (5.1.1)
|
|
98
|
-
addressable (~> 2.8)
|
|
99
|
-
http-cookie (~> 1.0)
|
|
100
|
-
http-form_data (~> 2.2)
|
|
101
|
-
llhttp-ffi (~> 0.4.0)
|
|
102
|
-
http-cookie (1.0.5)
|
|
103
|
-
domain_name (~> 0.5)
|
|
104
|
-
http-form_data (2.3.0)
|
|
105
88
|
i18n (1.15.2)
|
|
106
89
|
concurrent-ruby (~> 1.0)
|
|
107
90
|
json (2.20.0)
|
|
108
|
-
llhttp-ffi (0.4.0)
|
|
109
|
-
ffi-compiler (~> 1.0)
|
|
110
|
-
rake (~> 13.0)
|
|
111
91
|
logger (1.7.0)
|
|
112
92
|
minitest (6.0.6)
|
|
113
93
|
drb (~> 2.0)
|
|
@@ -174,9 +154,6 @@ GEM
|
|
|
174
154
|
tzinfo (2.0.6)
|
|
175
155
|
concurrent-ruby (~> 1.0)
|
|
176
156
|
unaccent (0.4.0)
|
|
177
|
-
unf (0.1.4)
|
|
178
|
-
unf_ext
|
|
179
|
-
unf_ext (0.0.8.2)
|
|
180
157
|
unicode-display_width (2.5.0)
|
|
181
158
|
uri (1.1.1)
|
|
182
159
|
webmock (3.14.0)
|
data/README.md
CHANGED
|
@@ -43,9 +43,18 @@ KB.config.log_level = :debugger # :info by default
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
#### Request timeout configuration
|
|
46
|
+
|
|
47
|
+
Timeouts are per phase, and each phase fails with its own error class:
|
|
48
|
+
`connect_timeout` maps to Net::HTTP's `open_timeout`, bounding TCP connect plus
|
|
49
|
+
the TLS handshake (`Net::OpenTimeout`); `read_timeout` bounds the wait for the
|
|
50
|
+
response (`Net::ReadTimeout`); `write_timeout` bounds sending the request
|
|
51
|
+
(`Net::WriteTimeout`).
|
|
52
|
+
|
|
46
53
|
```ruby
|
|
47
54
|
# config/initializers/kb_ruby.rb
|
|
48
|
-
KB.config.request.
|
|
55
|
+
KB.config.request.connect_timeout = 2 # 1 by default; TCP connect + TLS handshake
|
|
56
|
+
KB.config.request.write_timeout = 4 # 3 by default
|
|
57
|
+
KB.config.request.read_timeout = 10 # 5 by default
|
|
49
58
|
```
|
|
50
59
|
|
|
51
60
|
### Exposed Entities
|
data/barkibu-kb.gemspec
CHANGED
|
@@ -51,7 +51,7 @@ Gem::Specification.new do |spec|
|
|
|
51
51
|
spec.add_runtime_dependency 'activerecord'
|
|
52
52
|
spec.add_runtime_dependency 'activesupport', '>= 3.0.0'
|
|
53
53
|
spec.add_runtime_dependency 'faraday'
|
|
54
|
-
spec.add_runtime_dependency 'faraday-
|
|
54
|
+
spec.add_runtime_dependency 'faraday-net_http', '~> 1.0'
|
|
55
55
|
spec.add_runtime_dependency 'faraday_middleware'
|
|
56
56
|
spec.add_runtime_dependency 'i18n'
|
|
57
57
|
end
|
data/lib/barkibu-kb.rb
CHANGED
|
@@ -5,7 +5,6 @@ require 'active_support'
|
|
|
5
5
|
require 'active_support/core_ext/array'
|
|
6
6
|
require 'faraday'
|
|
7
7
|
require 'faraday_middleware'
|
|
8
|
-
require 'faraday/http'
|
|
9
8
|
require 'dry/configurable'
|
|
10
9
|
|
|
11
10
|
module KB
|
|
@@ -19,7 +18,9 @@ module KB
|
|
|
19
18
|
setting :log_level, default: :info
|
|
20
19
|
|
|
21
20
|
setting :request do
|
|
22
|
-
setting :
|
|
21
|
+
setting :connect_timeout, default: 1
|
|
22
|
+
setting :write_timeout, default: 3
|
|
23
|
+
setting :read_timeout, default: 5
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
data/lib/kb/client.rb
CHANGED
|
@@ -74,9 +74,7 @@ module KB
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def connection
|
|
77
|
-
@connection ||= Faraday.new(url: base_url,
|
|
78
|
-
headers: headers,
|
|
79
|
-
request: { timeout: KB.config.request.timeout }) do |conn|
|
|
77
|
+
@connection ||= Faraday.new(url: base_url, headers: headers, request: request_timeouts) do |conn|
|
|
80
78
|
conn.response :json
|
|
81
79
|
conn.response :raise_error
|
|
82
80
|
if KB.config.log_level == :debugger
|
|
@@ -84,8 +82,16 @@ module KB
|
|
|
84
82
|
logger.filter(/(X-api-key:\s)("\w+")/, '\1[API_KEY_SCRUBBED]')
|
|
85
83
|
end
|
|
86
84
|
end
|
|
87
|
-
conn.adapter :
|
|
85
|
+
conn.adapter :net_http
|
|
88
86
|
end
|
|
89
87
|
end
|
|
88
|
+
|
|
89
|
+
def request_timeouts
|
|
90
|
+
{
|
|
91
|
+
open_timeout: KB.config.request.connect_timeout,
|
|
92
|
+
write_timeout: KB.config.request.write_timeout,
|
|
93
|
+
read_timeout: KB.config.request.read_timeout
|
|
94
|
+
}
|
|
95
|
+
end
|
|
90
96
|
end
|
|
91
97
|
end
|
data/lib/kb/fake/api.rb
CHANGED
|
@@ -44,6 +44,16 @@ module KB
|
|
|
44
44
|
include BoundedContext::PetFamily::PetContracts
|
|
45
45
|
include BoundedContext::PetFamily::Products
|
|
46
46
|
|
|
47
|
+
# Sinatra >= 4.1 ships Rack::Protection::HostAuthorization, which authorizes
|
|
48
|
+
# on the Host header and, when it infers a development environment, only
|
|
49
|
+
# permits localhost-style hosts — rejecting requests addressed to the
|
|
50
|
+
# stubbed KB host with "403 Host not permitted". Permitting specific hosts
|
|
51
|
+
# on the consumer side is no fix either: with the net_http adapter WebMock
|
|
52
|
+
# intercepts before Net::HTTP adds the Host header, so the header is absent
|
|
53
|
+
# and can never match a permitted list. An empty list disables the check;
|
|
54
|
+
# it guards against DNS rebinding, which cannot apply to an in-process fake.
|
|
55
|
+
set :host_authorization, permitted_hosts: []
|
|
56
|
+
|
|
47
57
|
set :state, ApiState.new
|
|
48
58
|
|
|
49
59
|
def self.snapshot
|
data/lib/kb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: barkibu-kb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Léo Figea
|
|
@@ -220,19 +220,19 @@ dependencies:
|
|
|
220
220
|
- !ruby/object:Gem::Version
|
|
221
221
|
version: '0'
|
|
222
222
|
- !ruby/object:Gem::Dependency
|
|
223
|
-
name: faraday-
|
|
223
|
+
name: faraday-net_http
|
|
224
224
|
requirement: !ruby/object:Gem::Requirement
|
|
225
225
|
requirements:
|
|
226
|
-
- - "
|
|
226
|
+
- - "~>"
|
|
227
227
|
- !ruby/object:Gem::Version
|
|
228
|
-
version: '0'
|
|
228
|
+
version: '1.0'
|
|
229
229
|
type: :runtime
|
|
230
230
|
prerelease: false
|
|
231
231
|
version_requirements: !ruby/object:Gem::Requirement
|
|
232
232
|
requirements:
|
|
233
|
-
- - "
|
|
233
|
+
- - "~>"
|
|
234
234
|
- !ruby/object:Gem::Version
|
|
235
|
-
version: '0'
|
|
235
|
+
version: '1.0'
|
|
236
236
|
- !ruby/object:Gem::Dependency
|
|
237
237
|
name: faraday_middleware
|
|
238
238
|
requirement: !ruby/object:Gem::Requirement
|