restify 1.12.0 → 1.13.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 +8 -0
- data/README.md +9 -12
- data/lib/restify/adapter/em.rb +2 -2
- data/lib/restify/adapter/pooled_em.rb +5 -5
- data/lib/restify/adapter/typhoeus.rb +20 -12
- data/lib/restify/context.rb +1 -1
- data/lib/restify/global.rb +2 -2
- data/lib/restify/version.rb +1 -1
- data/spec/restify/context_spec.rb +2 -2
- data/spec/restify/error_spec.rb +0 -1
- data/spec/restify/global_spec.rb +1 -1
- data/spec/restify_spec.rb +0 -2
- data/spec/spec_helper.rb +1 -1
- 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: e2b5dacc128de6cbfed604453544f51eaeffd16b9b6cb83f5353ecca66d24a8d
|
4
|
+
data.tar.gz: 5c3eba335362aea288f851327fa96262e5b464b9a747b092955241bb362e9c0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32569c3544a1ac6734b3c81c1e2b6a46ea7dba324c1f71f5e85bd1df93b8b73bb70114a7cec37dd8e38e561a821e674e8c437c78757d78df75e1e51b1a5a79f8
|
7
|
+
data.tar.gz: 6f03d156fcc20e0dfba3d7fda0a5c7851ff5d9342fbb9b50c4d90d1f43bf65e92f0ecabb714c4023ce4ca8cfb95b231abd7ea5d1e05339e839ea046b17f3d1fe
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
18
18
|
### Breaks
|
19
19
|
|
20
20
|
|
21
|
+
## 1.13.0 - (2020-06-12)
|
22
|
+
---
|
23
|
+
|
24
|
+
### New
|
25
|
+
* typhoeus: Support setting per-request libcurl options on adapter
|
26
|
+
* typhoeus: Enable short TCP keepalive probes by default (5s/5s)
|
27
|
+
|
28
|
+
|
21
29
|
## 1.12.0 - (2020-04-01)
|
22
30
|
---
|
23
31
|
|
data/README.md
CHANGED
@@ -15,20 +15,17 @@ Restify is build upon the following libraries:
|
|
15
15
|
* [addressable](https://github.com/sporkmonger/addressable)
|
16
16
|
* [typhoeus](https://github.com/typhoeus/typhoeus)
|
17
17
|
|
18
|
-
It has optional HTTP adapters using:
|
19
|
-
|
20
|
-
* [em-http-request](https://github.com/igrigorik/em-http-request)
|
21
|
-
|
22
18
|
The HTTP adapters are mostly run in a background thread and may not survive mid-application forks.
|
23
19
|
|
24
|
-
|
20
|
+
Restify includes processors to parse responses and to extract links between resources. The following formats are can be parsed:
|
25
21
|
|
26
|
-
*
|
27
|
-
* MessagePack
|
22
|
+
* JSON
|
23
|
+
* MessagePack
|
28
24
|
|
29
|
-
|
25
|
+
Links are extracted from
|
30
26
|
|
31
|
-
|
27
|
+
* HTTP Link header
|
28
|
+
* Github-style relations in payloads
|
32
29
|
|
33
30
|
### Planned features
|
34
31
|
|
@@ -106,9 +103,9 @@ commit = repo.rel(:commits).get.value.first
|
|
106
103
|
And print it:
|
107
104
|
|
108
105
|
```ruby
|
109
|
-
puts "Last commit: #{commit[
|
110
|
-
puts "By #{commit[
|
111
|
-
puts "#{commit[
|
106
|
+
puts "Last commit: #{commit['sha']}"
|
107
|
+
puts "By #{commit['commit']['author']['name']} <#{commit['commit']['author']['email']}>"
|
108
|
+
puts "#{commit['commit']['message']}"
|
112
109
|
```
|
113
110
|
|
114
111
|
See commented example in main spec [`spec/restify_spec.rb`](https://github.com/jgraichen/restify/blob/master/spec/restify_spec.rb#L100) or in the `examples` directory.
|
data/lib/restify/adapter/em.rb
CHANGED
@@ -63,8 +63,8 @@ module Restify
|
|
63
63
|
query: request.uri.normalized_query,
|
64
64
|
body: request.body,
|
65
65
|
head: request.headers
|
66
|
-
rescue Exception =>
|
67
|
-
writer.reject
|
66
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
67
|
+
writer.reject e
|
68
68
|
requests.shift unless pipeline?
|
69
69
|
return
|
70
70
|
end
|
@@ -200,9 +200,9 @@ module Restify
|
|
200
200
|
@pool = Pool.new(**kwargs)
|
201
201
|
end
|
202
202
|
|
203
|
-
# rubocop:disable MethodLength
|
204
|
-
# rubocop:disable AbcSize
|
205
|
-
# rubocop:disable BlockLength
|
203
|
+
# rubocop:disable Metrics/MethodLength
|
204
|
+
# rubocop:disable Metrics/AbcSize
|
205
|
+
# rubocop:disable Metrics/BlockLength
|
206
206
|
def call_native(request, writer)
|
207
207
|
next_tick do
|
208
208
|
defer = @pool.get(request)
|
@@ -241,9 +241,9 @@ module Restify
|
|
241
241
|
@pool.remove(conn)
|
242
242
|
writer.reject(req.error)
|
243
243
|
end
|
244
|
-
rescue Exception =>
|
244
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
245
245
|
@pool.remove(conn)
|
246
|
-
writer.reject(
|
246
|
+
writer.reject(e)
|
247
247
|
end
|
248
248
|
end
|
249
249
|
end
|
@@ -16,20 +16,28 @@ module Restify
|
|
16
16
|
'Transfer-Encoding' => ''
|
17
17
|
}.freeze
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
DEFAULT_OPTIONS = {
|
20
|
+
followlocation: true,
|
21
|
+
tcp_keepalive: true,
|
22
|
+
tcp_keepidle: 5,
|
23
|
+
tcp_keepintvl: 5
|
24
|
+
}.freeze
|
25
|
+
|
26
|
+
def initialize(sync: false, options: {}, **kwargs)
|
27
|
+
@sync = sync
|
28
|
+
@hydra = ::Typhoeus::Hydra.new(**kwargs)
|
29
|
+
@mutex = Mutex.new
|
30
|
+
@signal = ConditionVariable.new
|
31
|
+
@thread = nil
|
32
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
25
33
|
end
|
26
34
|
|
27
35
|
def sync?
|
28
36
|
@sync
|
29
37
|
end
|
30
38
|
|
31
|
-
# rubocop:disable AbcSize
|
32
|
-
# rubocop:disable MethodLength
|
39
|
+
# rubocop:disable Metrics/AbcSize
|
40
|
+
# rubocop:disable Metrics/MethodLength
|
33
41
|
def call_native(request, writer)
|
34
42
|
req = convert(request, writer)
|
35
43
|
|
@@ -57,15 +65,15 @@ module Restify
|
|
57
65
|
|
58
66
|
private
|
59
67
|
|
60
|
-
# rubocop:disable AbcSize
|
61
|
-
# rubocop:disable MethodLength
|
68
|
+
# rubocop:disable Metrics/AbcSize
|
69
|
+
# rubocop:disable Metrics/MethodLength
|
62
70
|
def convert(request, writer)
|
63
71
|
::Typhoeus::Request.new(
|
64
72
|
request.uri,
|
73
|
+
**@options,
|
65
74
|
method: request.method,
|
66
75
|
headers: DEFAULT_HEADERS.merge(request.headers),
|
67
76
|
body: request.body,
|
68
|
-
followlocation: true,
|
69
77
|
timeout: request.timeout,
|
70
78
|
connecttimeout: request.timeout
|
71
79
|
).tap do |req|
|
@@ -124,7 +132,7 @@ module Restify
|
|
124
132
|
@hydra.queued_requests.any? || @hydra.multi.easy_handles.any?
|
125
133
|
end
|
126
134
|
|
127
|
-
# rubocop:disable MethodLength
|
135
|
+
# rubocop:disable Metrics/MethodLength
|
128
136
|
def _run
|
129
137
|
debug 'hydra:run'
|
130
138
|
@hydra.run while _ongoing?
|
data/lib/restify/context.rb
CHANGED
data/lib/restify/global.rb
CHANGED
@@ -39,9 +39,9 @@ module Restify
|
|
39
39
|
|
40
40
|
def resolve_context(uri, **opts)
|
41
41
|
if uri.is_a? Symbol
|
42
|
-
Restify::Registry.fetch(uri).inherit(nil, opts)
|
42
|
+
Restify::Registry.fetch(uri).inherit(nil, **opts)
|
43
43
|
else
|
44
|
-
Context.new
|
44
|
+
Context.new(uri, **opts)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/restify/version.rb
CHANGED
@@ -47,7 +47,7 @@ describe Restify::Context do
|
|
47
47
|
|
48
48
|
context 'YAML' do
|
49
49
|
let(:dump) { YAML.dump(context) }
|
50
|
-
let(:load) { YAML.load(dump) } # rubocop:disable YAMLLoad
|
50
|
+
let(:load) { YAML.load(dump) } # rubocop:disable Security/YAMLLoad
|
51
51
|
|
52
52
|
subject { load }
|
53
53
|
|
@@ -56,7 +56,7 @@ describe Restify::Context do
|
|
56
56
|
|
57
57
|
context 'Marshall' do
|
58
58
|
let(:dump) { Marshal.dump(context) }
|
59
|
-
let(:load) { Marshal.load(dump) } # rubocop:disable MarshalLoad
|
59
|
+
let(:load) { Marshal.load(dump) } # rubocop:disable Security/MarshalLoad
|
60
60
|
|
61
61
|
subject { load }
|
62
62
|
|
data/spec/restify/error_spec.rb
CHANGED
data/spec/restify/global_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Restify::Global do
|
|
26
26
|
let(:options) { {accept: 'application.vnd.github.v3+json'} }
|
27
27
|
let(:context) { Restify::Context.new uri, **options }
|
28
28
|
|
29
|
-
subject { global.new
|
29
|
+
subject { global.new(name, **options) }
|
30
30
|
|
31
31
|
it 'returns relation for stored registry item' do
|
32
32
|
Restify::Registry.store name, uri, options
|
data/spec/restify_spec.rb
CHANGED
@@ -134,7 +134,6 @@ describe Restify do
|
|
134
134
|
# the result is here.
|
135
135
|
expect { create_user_promise.value! }.to \
|
136
136
|
raise_error(Restify::ClientError) do |e|
|
137
|
-
|
138
137
|
# Because we forgot to send a "name" the server complains
|
139
138
|
# with an error code that will lead to a raised error.
|
140
139
|
|
@@ -206,7 +205,6 @@ describe Restify do
|
|
206
205
|
|
207
206
|
expect { create_user_promise.value! }.to \
|
208
207
|
raise_error(Restify::ClientError) do |e|
|
209
|
-
|
210
208
|
expect(e.status).to eq :unprocessable_entity
|
211
209
|
expect(e.code).to eq 422
|
212
210
|
expect(e.errors).to eq 'name' => ["can't be blank"]
|
data/spec/spec_helper.rb
CHANGED
@@ -38,7 +38,7 @@ require 'webmock/rspec'
|
|
38
38
|
require 'rspec/collection_matchers'
|
39
39
|
require 'em-synchrony'
|
40
40
|
|
41
|
-
Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
|
41
|
+
Dir[File.expand_path('spec/support/**/*.rb')].sort.each {|f| require f }
|
42
42
|
|
43
43
|
RSpec.configure do |config|
|
44
44
|
config.order = 'random'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|