restify 3.0.0.rc3 → 3.0.0.rc4
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 +1 -1
- data/lib/restify/adapter/ethon/event_loop.rb +0 -3
- data/lib/restify/adapter/ethon/pool.rb +0 -1
- data/lib/restify/adapter/ethon.rb +33 -14
- data/lib/restify/version.rb +1 -1
- data/spec/restify/adapter/ethon/event_loop_spec.rb +0 -9
- data/spec/restify/adapter/ethon/pool_spec.rb +3 -5
- data/spec/restify/adapter/ethon_spec.rb +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6bba240439ce24aa207d7bd4b74fb009e726858ff74fbee936d949bca4c3b45f
|
|
4
|
+
data.tar.gz: 76babe54df30e32579475f3f5380a87344ab8b7054777518f52d9bb4a99c5ee6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a188e03abeef79ce84d41675b0ce0e4747fdd94dce07c1f9bcfebde304026f86d5c88ba0483ed4b8122d705df085f493742b3e00463242d3aa5db8accb2a88fe
|
|
7
|
+
data.tar.gz: b02fbee6a328346d59933153608da137fdec14491a3e0c870142767673c1b5282be8b854824e5d4a6e7be05b37fbc05bec4956f86bc519f9d8c523c37672c1f9
|
data/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
17
17
|
|
|
18
18
|
### Breaks
|
|
19
19
|
|
|
20
|
+
## 3.0.0-rc4 - (2026-11-22)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### Breaks
|
|
25
|
+
|
|
26
|
+
- Require Ethon 0.19. If libcurl was already used before forking, new requests in a forked child process require calling `Ethon::Curl.allow_handles_after_fork!` first.
|
|
27
|
+
|
|
20
28
|
## 3.0.0-rc3 - (2026-09-27)
|
|
21
29
|
|
|
22
30
|
---
|
data/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Restify uses libcurl via Ethon by default. The older [Typhoeus](https://github.c
|
|
|
20
20
|
Restify.adapter = Restify::Adapter::Typhoeus.new
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
The default Ethon adapter should work with forking, e.g. in Puma or Unicorn workers. Requests still pending when forking are aborted in the child process.
|
|
23
|
+
The default Ethon adapter should work with forking, e.g. in Puma or Unicorn workers. Requests still pending when forking are aborted in the child process. If libcurl was already used before forking, Ethon only allows new requests in the child process after calling `Ethon::Curl.allow_handles_after_fork!`, e.g. in Puma's `before_worker_boot` hook (not supported on macOS).
|
|
24
24
|
|
|
25
25
|
Restify includes processors to parse responses and to extract links between resources. The following formats are can be parsed:
|
|
26
26
|
|
|
@@ -109,10 +109,7 @@ module Restify
|
|
|
109
109
|
pending = @multi.easy_handles.dup
|
|
110
110
|
pending << @queue.pop(true) until @queue.empty?
|
|
111
111
|
|
|
112
|
-
@multi.handle.autorelease = false
|
|
113
|
-
|
|
114
112
|
pending.each do |easy|
|
|
115
|
-
easy.handle.autorelease = false
|
|
116
113
|
easy._restify_writer.reject(
|
|
117
114
|
Restify::NetworkError.new(
|
|
118
115
|
easy._restify_request,
|
|
@@ -85,7 +85,7 @@ module Restify
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
def call_native(request, writer)
|
|
88
|
-
|
|
88
|
+
setup
|
|
89
89
|
|
|
90
90
|
easy = convert(request, writer)
|
|
91
91
|
|
|
@@ -111,12 +111,18 @@ module Restify
|
|
|
111
111
|
# only run in the thread waiting on them.
|
|
112
112
|
#
|
|
113
113
|
# Returns false when the loop cannot be run in the calling thread,
|
|
114
|
-
# i.e. when waiting from within the loop itself
|
|
114
|
+
# i.e. when waiting from within the loop itself, or when there is
|
|
115
|
+
# no loop in this process (anymore).
|
|
115
116
|
#
|
|
116
117
|
def drive(promise, timeout)
|
|
117
|
-
|
|
118
|
+
events = @mutex.synchronize do
|
|
119
|
+
forked! if forked?
|
|
120
|
+
@events
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
return false unless events
|
|
118
124
|
|
|
119
|
-
|
|
125
|
+
events.drive(promise, timeout)
|
|
120
126
|
end
|
|
121
127
|
|
|
122
128
|
private
|
|
@@ -125,30 +131,43 @@ module Restify
|
|
|
125
131
|
self
|
|
126
132
|
end
|
|
127
133
|
|
|
134
|
+
# Set up the event loop and handle pool, unless already done in
|
|
135
|
+
# the current process.
|
|
136
|
+
#
|
|
137
|
+
# In a forked child, Ethon raises `Ethon::Errors::ForkSafety` here
|
|
138
|
+
# if libcurl was already initialized before the fork, unless the
|
|
139
|
+
# application called `Ethon::Curl.allow_handles_after_fork!`.
|
|
128
140
|
def setup
|
|
129
|
-
@pid = Process.pid
|
|
130
|
-
@pool = Pool.new(size: POOL_SIZE) { Easy.new }
|
|
131
|
-
@events = EventLoop.new(**@multi_options)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def check_fork!
|
|
135
141
|
return if @pid == Process.pid
|
|
136
142
|
|
|
137
|
-
@mutex.synchronize
|
|
143
|
+
@mutex.synchronize do
|
|
144
|
+
forked! if forked?
|
|
145
|
+
next if @pid
|
|
146
|
+
|
|
147
|
+
@pool = Pool.new(size: POOL_SIZE) { Easy.new }
|
|
148
|
+
@events = EventLoop.new(**@multi_options)
|
|
149
|
+
@pid = Process.pid
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def forked?
|
|
154
|
+
!@pid.nil? && @pid != Process.pid
|
|
138
155
|
end
|
|
139
156
|
|
|
140
157
|
# A forked child process inherits the parent's event loop,
|
|
141
158
|
# connections and sockets. They must neither be used nor cleaned
|
|
142
159
|
# up here, as the parent still uses them.
|
|
143
160
|
#
|
|
144
|
-
# Therefore, abandon the state without releasing it
|
|
145
|
-
#
|
|
161
|
+
# Therefore, abandon the state without releasing it. A new event
|
|
162
|
+
# loop is only set up with the next request.
|
|
146
163
|
def forked!
|
|
147
164
|
@events.forked!
|
|
148
165
|
@pool.forked!
|
|
149
166
|
|
|
167
|
+
@events = nil
|
|
168
|
+
@pool = nil
|
|
150
169
|
@thread = nil
|
|
151
|
-
|
|
170
|
+
@pid = nil
|
|
152
171
|
end
|
|
153
172
|
|
|
154
173
|
def convert(request, writer)
|
data/lib/restify/version.rb
CHANGED
|
@@ -83,14 +83,5 @@ describe Restify::Adapter::Ethon::EventLoop do
|
|
|
83
83
|
expect(promise.reason).to be_a Restify::NetworkError
|
|
84
84
|
expect(promise.reason.message).to include 'Request started before fork'
|
|
85
85
|
end
|
|
86
|
-
|
|
87
|
-
it 'does not release pending handles' do
|
|
88
|
-
easy, = transfer
|
|
89
|
-
events.enqueue(easy)
|
|
90
|
-
|
|
91
|
-
events.forked!
|
|
92
|
-
|
|
93
|
-
expect(easy.handle.autorelease?).to be false
|
|
94
|
-
end
|
|
95
86
|
end
|
|
96
87
|
end
|
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
|
5
5
|
describe Restify::Adapter::Ethon::Pool do
|
|
6
6
|
subject(:pool) do
|
|
7
7
|
described_class.new(size: 2) do
|
|
8
|
-
created << Handle.new(0
|
|
8
|
+
created << Handle.new(0)
|
|
9
9
|
created.last
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -13,8 +13,7 @@ describe Restify::Adapter::Ethon::Pool do
|
|
|
13
13
|
let(:created) { [] }
|
|
14
14
|
|
|
15
15
|
before do
|
|
16
|
-
stub_const('
|
|
17
|
-
stub_const('Handle', Struct.new(:resets, :handle) do
|
|
16
|
+
stub_const('Handle', Struct.new(:resets) do
|
|
18
17
|
def reset
|
|
19
18
|
self.resets += 1
|
|
20
19
|
end
|
|
@@ -68,13 +67,12 @@ describe Restify::Adapter::Ethon::Pool do
|
|
|
68
67
|
end
|
|
69
68
|
|
|
70
69
|
describe '#forked!' do
|
|
71
|
-
it '
|
|
70
|
+
it 'forgets idle handles' do
|
|
72
71
|
idle = pool.checkout
|
|
73
72
|
release(idle)
|
|
74
73
|
|
|
75
74
|
pool.forked!
|
|
76
75
|
|
|
77
|
-
expect(idle.handle.autorelease).to be false
|
|
78
76
|
expect(pool.checkout).not_to be idle
|
|
79
77
|
end
|
|
80
78
|
end
|
|
@@ -280,6 +280,11 @@ describe Restify::Adapter::Ethon do
|
|
|
280
280
|
expect(Array.new(2) { connects.pop(timeout: 1) }).to eq [1, 0]
|
|
281
281
|
|
|
282
282
|
result = in_child do
|
|
283
|
+
# Ethon refuses new handles in a child of a process that already
|
|
284
|
+
# used libcurl, unless the application opts in, e.g. in a Puma
|
|
285
|
+
# `before_worker_boot` hook.
|
|
286
|
+
Ethon::Curl.allow_handles_after_fork!
|
|
287
|
+
|
|
283
288
|
code = adapter.call(request('fast')).value!.code
|
|
284
289
|
[code, connects.pop(timeout: 1)]
|
|
285
290
|
end
|
|
@@ -303,5 +308,13 @@ describe Restify::Adapter::Ethon do
|
|
|
303
308
|
expect(result).to include 'before fork'
|
|
304
309
|
expect(promise.value!.code).to eq 200
|
|
305
310
|
end
|
|
311
|
+
|
|
312
|
+
it 'leaves new requests in the child process to Ethon\'s fork safety' do
|
|
313
|
+
adapter.call(request('fast')).value!
|
|
314
|
+
|
|
315
|
+
result = in_child { adapter.call(request('fast')) }
|
|
316
|
+
|
|
317
|
+
expect(result).to be_a Ethon::Errors::ForkSafety
|
|
318
|
+
end
|
|
306
319
|
end
|
|
307
320
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: restify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.0.
|
|
4
|
+
version: 3.0.0.rc4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Graichen
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.19.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.19.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: msgpack
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|