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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19ee2486506eef195ed64b0a37ff921b97fefa46356e69d2fc3b28ca404ebf98
4
- data.tar.gz: 3b81f57ac5b84452dc9e9b6e1bb39705b601138ee5e5f9e2d1bb33d1107e286f
3
+ metadata.gz: e2b5dacc128de6cbfed604453544f51eaeffd16b9b6cb83f5353ecca66d24a8d
4
+ data.tar.gz: 5c3eba335362aea288f851327fa96262e5b464b9a747b092955241bb362e9c0d
5
5
  SHA512:
6
- metadata.gz: e2e87e8c7e31b32d7da5f70321887a7ca28831a78e088fe3c934a08dc94481413d4a24c64eb8f765d60c7195a2d9830a11d11df6fa7c9c96ee5033ae26659f80
7
- data.tar.gz: 58697191071fa894417566779fcca6f74bb817ae6173bf9d7752b91af0b252d5ae4911fd29507b04fe6adf327e8b73cbf5109509fd9771078936259cb1911e46
6
+ metadata.gz: 32569c3544a1ac6734b3c81c1e2b6a46ea7dba324c1f71f5e85bd1df93b8b73bb70114a7cec37dd8e38e561a821e674e8c437c78757d78df75e1e51b1a5a79f8
7
+ data.tar.gz: 6f03d156fcc20e0dfba3d7fda0a5c7851ff5d9342fbb9b50c4d90d1f43bf65e92f0ecabb714c4023ce4ca8cfb95b231abd7ea5d1e05339e839ea046b17f3d1fe
@@ -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
- Included processors can handle:
20
+ Restify includes processors to parse responses and to extract links between resources. The following formats are can be parsed:
25
21
 
26
- * Plain JSON with GitHub-style relations
27
- * MessagePack with GitHub-style relations *(currently experimental)*
22
+ * JSON
23
+ * MessagePack
28
24
 
29
- (Beside HTTP Link header that's always supported)
25
+ Links are extracted from
30
26
 
31
- Restify requires Ruby 2.0+.
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[:sha]}"
110
- puts "By #{commit[:commit][:author][:name]} <#{commit[:commit][:author][:email]}>"
111
- puts "#{commit[:commit][:message]}"
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.
@@ -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 => err # rubocop:disable RescueException
67
- writer.reject err
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 => ex # rubocop:disable RescueException
244
+ rescue Exception => e # rubocop:disable Lint/RescueException
245
245
  @pool.remove(conn)
246
- writer.reject(ex)
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
- def initialize(sync: false, **options)
20
- @sync = sync
21
- @hydra = ::Typhoeus::Hydra.new(**options)
22
- @mutex = Mutex.new
23
- @signal = ConditionVariable.new
24
- @thread = nil
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?
@@ -36,7 +36,7 @@ module Restify
36
36
 
37
37
  def inherit(uri, **kwargs)
38
38
  uri ||= self.uri
39
- Context.new uri, kwargs.merge(options)
39
+ Context.new(uri, **kwargs, **options)
40
40
  end
41
41
 
42
42
  def process(response)
@@ -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 uri, opts
44
+ Context.new(uri, **opts)
45
45
  end
46
46
  end
47
47
  end
@@ -3,7 +3,7 @@
3
3
  module Restify
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 12
6
+ MINOR = 13
7
7
  PATCH = 0
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
@@ -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
 
@@ -14,7 +14,6 @@ describe Restify::ResponseError do
14
14
  allow(response).to receive(:decoded_body).and_return({})
15
15
  end
16
16
 
17
-
18
17
  describe '.from_code' do
19
18
  subject(:err) { described_class.from_code(response) }
20
19
 
@@ -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 name, options }
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
@@ -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"]
@@ -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.12.0
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-04-01 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport