barkibu-kb 1.0.0 → 1.1.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/.github/workflows/ci.yml +27 -0
- data/CHANGELOG.md +4 -1
- data/Gemfile.lock +3 -3
- data/README.md +17 -0
- data/lib/kb/client.rb +13 -3
- data/lib/kb/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6665ca6f0d74295cacf6bea9ee921b3dba5decc6b5cb3775bbaa0392fd65b86
|
|
4
|
+
data.tar.gz: 700cae8005557d25ff41c3f9583725686485eff37ccbb0eec11ff07473ad9077
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97dac9ae9946f9398bd62b2fda16acbd978c1e4e153e23884ab78ac3a055dec7d201fcbf3a98ed4b65403324af2b03d034a6073f30d15c20690699021fccae74
|
|
7
|
+
data.tar.gz: f9ed89dff91778420037ad50e7531af48d9b7b6d11c7d92afb1d05cdc31192498310520da51d35aa32e9ed77041e808137f5d9b699fcea24d495f2d17379b475
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [master]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
rubocop:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v5
|
|
13
|
+
- uses: ruby/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: '3.4'
|
|
16
|
+
bundler-cache: true
|
|
17
|
+
- run: bundle exec rubocop lib spec
|
|
18
|
+
|
|
19
|
+
rspec:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v5
|
|
23
|
+
- uses: ruby/setup-ruby@v1
|
|
24
|
+
with:
|
|
25
|
+
ruby-version: '3.4'
|
|
26
|
+
bundler-cache: true
|
|
27
|
+
- run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,10 @@ 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/v1.
|
|
9
|
+
- See diff: https://github.com/barkibu/kb-ruby/compare/v1.1.0...HEAD
|
|
10
|
+
|
|
11
|
+
## [1.1.0]
|
|
12
|
+
- Add `read_timeout:` to `KB::Client#request` to raise the read budget for a single call (e.g. `GET /v1/pets/birthdays`, whose server-side work runs for seconds). Connect and write budgets stay global; the override does not leak into later calls on the same connection.
|
|
10
13
|
|
|
11
14
|
## [1.0.0]
|
|
12
15
|
- [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`).
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
barkibu-kb (1.
|
|
4
|
+
barkibu-kb (1.1.0)
|
|
5
5
|
activemodel (>= 4.0.2)
|
|
6
6
|
activerecord
|
|
7
7
|
activesupport (>= 3.0.0)
|
|
@@ -10,8 +10,8 @@ PATH
|
|
|
10
10
|
faraday-net_http (~> 1.0)
|
|
11
11
|
faraday_middleware
|
|
12
12
|
i18n
|
|
13
|
-
barkibu-kb-fake (1.
|
|
14
|
-
barkibu-kb (= 1.
|
|
13
|
+
barkibu-kb-fake (1.1.0)
|
|
14
|
+
barkibu-kb (= 1.1.0)
|
|
15
15
|
countries
|
|
16
16
|
sinatra
|
|
17
17
|
webmock
|
data/README.md
CHANGED
|
@@ -18,6 +18,15 @@ Or install it yourself as:
|
|
|
18
18
|
|
|
19
19
|
$ gem install kb
|
|
20
20
|
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
Specs and RuboCop run on every pull request (`.github/workflows/ci.yml`) on Ruby 3.4. Locally:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
docker compose run --rm kb bundle exec rspec
|
|
27
|
+
docker compose run --rm kb bundle exec rubocop lib spec
|
|
28
|
+
```
|
|
29
|
+
|
|
21
30
|
## Usage
|
|
22
31
|
|
|
23
32
|
This gem wraps the Knowledge Base Api and exposes CRUD-_able_ entities into the requiring application.
|
|
@@ -57,6 +66,14 @@ KB.config.request.write_timeout = 4 # 3 by default
|
|
|
57
66
|
KB.config.request.read_timeout = 10 # 5 by default
|
|
58
67
|
```
|
|
59
68
|
|
|
69
|
+
The read budget can be raised for a single call through `KB::Client#request`, for
|
|
70
|
+
the few endpoints whose server-side work legitimately runs for seconds. Connect
|
|
71
|
+
and write budgets stay global:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
KB::Pet.kb_client.request('birthdays', filters: { month: 9, day: 22, size: 1000 }, read_timeout: 30)
|
|
75
|
+
```
|
|
76
|
+
|
|
60
77
|
### Exposed Entities
|
|
61
78
|
|
|
62
79
|
#### Pet Parent 🧍🏾
|
data/lib/kb/client.rb
CHANGED
|
@@ -7,12 +7,16 @@ module KB
|
|
|
7
7
|
@base_url = base_url
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# `read_timeout` overrides KB.config.request.read_timeout for this one call only,
|
|
11
|
+
# for the few endpoints whose server-side work legitimately runs for seconds
|
|
12
|
+
# (e.g. GET /v1/pets/birthdays). Connect and write budgets stay global.
|
|
13
|
+
def request(sub_path, filters: nil, method: :get, read_timeout: nil)
|
|
14
|
+
options = request_options(read_timeout)
|
|
15
|
+
return connection.public_send(method, sub_path, attributes_to_json(filters), &options).body if method != :get
|
|
12
16
|
|
|
13
17
|
cache_key = "#{@base_url}/#{sub_path}/#{(filters || {}).sort.to_h}"
|
|
14
18
|
KB::Cache.fetch(cache_key) do
|
|
15
|
-
connection.public_send(method, sub_path, filters).body
|
|
19
|
+
connection.public_send(method, sub_path, filters, &options).body
|
|
16
20
|
end
|
|
17
21
|
end
|
|
18
22
|
|
|
@@ -86,6 +90,12 @@ module KB
|
|
|
86
90
|
end
|
|
87
91
|
end
|
|
88
92
|
|
|
93
|
+
def request_options(read_timeout)
|
|
94
|
+
return nil if read_timeout.nil?
|
|
95
|
+
|
|
96
|
+
->(req) { req.options.read_timeout = read_timeout }
|
|
97
|
+
end
|
|
98
|
+
|
|
89
99
|
def request_timeouts
|
|
90
100
|
{
|
|
91
101
|
open_timeout: KB.config.request.connect_timeout,
|
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: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Léo Figea
|
|
@@ -271,6 +271,7 @@ extra_rdoc_files: []
|
|
|
271
271
|
files:
|
|
272
272
|
- ".env.example"
|
|
273
273
|
- ".github/pull_request_template.md"
|
|
274
|
+
- ".github/workflows/ci.yml"
|
|
274
275
|
- ".github/workflows/release.yaml"
|
|
275
276
|
- ".gitignore"
|
|
276
277
|
- ".rspec"
|