rack-timeout 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +9 -0
- data/Gemfile +3 -0
- data/README.markdown +35 -37
- data/Rakefile +9 -0
- data/lib/rack/timeout/core.rb +9 -8
- data/lib/rack/timeout/logging-observer.rb +3 -0
- data/lib/rack/timeout/rails.rb +7 -2
- data/lib/rack/timeout/rollbar.rb +1 -53
- data/lib/rack/timeout/support/scheduler.rb +6 -0
- data/test/basic_test.rb +32 -0
- metadata +53 -7
- data/lib/rack/timeout/legacy.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9883fb70f10b92813db0e39769ab134f581c62a
|
4
|
+
data.tar.gz: a31ef775470b03bedeb09981dd9e4d5967879518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a1b07a8dcf61cb71ef95300eb03b8b7b2a2a436def96fd832d4438d46fc09dc0419d51c15340b52c7022ffabff25c3db60b8e575c7c90bd18bc2e733bbcb2d0
|
7
|
+
data.tar.gz: a6e9ff8614f66a81086125b80037b7e4610860f6e5aea41be08305f477ad825f0e984171e55a83ae7e1e6baa1237b38691b9e89fc394dd146e41e82b932634ba
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.5.0
|
2
|
+
=====
|
3
|
+
- Add support to configure via environment variables (#105)
|
4
|
+
- Adds support for ActionDispatch::RequestId generated request ids (#115)
|
5
|
+
- Changes uuid format to proper uuid (#115)
|
6
|
+
- Remove Rollbar module (#124)
|
7
|
+
- Remove legacy class setters (#125)
|
8
|
+
|
1
9
|
0.4.2
|
2
10
|
=====
|
3
11
|
- Ruby 2.0 compatible
|
@@ -13,6 +21,7 @@
|
|
13
21
|
- Settings are now passable to the middleware initializer instead of class-level
|
14
22
|
- Rollbar module may take a custom fingerprint block
|
15
23
|
- Rollbar module considered final
|
24
|
+
- Fixed an issue where some heartbeats would live on forever (#103, /ht @0x0badc0de)
|
16
25
|
|
17
26
|
0.3.2
|
18
27
|
=====
|
data/Gemfile
ADDED
data/README.markdown
CHANGED
@@ -22,14 +22,7 @@ The following covers currently supported versions of Rails, Rack, Ruby, and Bund
|
|
22
22
|
gem "rack-timeout"
|
23
23
|
```
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
To use a custom timeout, create an initializer file:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
# config/initializers/rack_timeout.rb
|
31
|
-
Rack::Timeout.service_timeout = 5 # seconds
|
32
|
-
```
|
25
|
+
This will load rack-timeout and set it up as a Rails middleware using the default timeout of 15s. The middleware is not inserted for the test environment. You can modify the timeout by setting a `RACK_TIMEOUT_SERVICE_TIMEOUT` environment variable.
|
33
26
|
|
34
27
|
### Rails apps, manually
|
35
28
|
|
@@ -43,7 +36,7 @@ gem "rack-timeout", require:"rack/timeout/base"
|
|
43
36
|
```ruby
|
44
37
|
# config/initializers/rack_timeout.rb
|
45
38
|
|
46
|
-
# insert middleware wherever you want in the stack, optionally pass initialization arguments
|
39
|
+
# insert middleware wherever you want in the stack, optionally pass initialization arguments or use environment variables
|
47
40
|
Rails.application.config.middleware.insert_before Rack::Runtime, Rack::Timeout, service_timeout: 5
|
48
41
|
```
|
49
42
|
|
@@ -54,7 +47,7 @@ Rails.application.config.middleware.insert_before Rack::Runtime, Rack::Timeout,
|
|
54
47
|
require "rack-timeout"
|
55
48
|
|
56
49
|
# Call as early as possible so rack-timeout runs before all other middleware.
|
57
|
-
# Setting service_timeout is recommended. If omitted, defaults to 15 seconds.
|
50
|
+
# Setting service_timeout or `RACK_TIMEOUT_SERVICE_TIMEOUT` environment variable is recommended. If omitted, defaults to 15 seconds.
|
58
51
|
use Rack::Timeout, service_timeout: 5
|
59
52
|
```
|
60
53
|
|
@@ -65,21 +58,18 @@ The Rabbit Hole
|
|
65
58
|
Rack::Timeout takes the following settings, shown here with their default values:
|
66
59
|
|
67
60
|
```
|
68
|
-
service_timeout: 15
|
69
|
-
wait_timeout: 30
|
70
|
-
wait_overtime: 60
|
71
|
-
service_past_wait: false
|
61
|
+
service_timeout: 15 # RACK_TIMEOUT_SERVICE_TIMEOUT
|
62
|
+
wait_timeout: 30 # RACK_TIMEOUT_WAIT_TIMEOUT
|
63
|
+
wait_overtime: 60 # RACK_TIMEOUT_WAIT_OVERTIME
|
64
|
+
service_past_wait: false # RACK_TIMEOUT_SERVICE_PAST_WAIT
|
72
65
|
```
|
73
66
|
|
74
|
-
As shown earlier, these settings can be overriden during middleware initialization:
|
67
|
+
As shown earlier, these settings can be overriden during middleware initialization or environment variables `RACK_TIMEOUT_*` mentioned above. Middleware parameters take precedence:
|
75
68
|
|
76
69
|
```ruby
|
77
70
|
use Rack::Timeout, service_timeout: 5, wait_timeout: false
|
78
71
|
```
|
79
72
|
|
80
|
-
For legacy reasons, it's also possible to set these at the class level (e.g. `Rack::Timeout.service_timeout = 3`). This is, however, not recommended. Also beware this style takes precedence over all instances' initialization settings.
|
81
|
-
|
82
|
-
|
83
73
|
### Service Timeout
|
84
74
|
|
85
75
|
`service_timeout` is our most important setting.
|
@@ -102,7 +92,7 @@ On Heroku, a request will be dropped when the routing layer sees no data being t
|
|
102
92
|
|
103
93
|
Wait timeout can be disabled entirely by setting the property to `0` or `false`.
|
104
94
|
|
105
|
-
A request's computed wait time may affect the service timeout used for it. Basically, a request's wait time plus service time may not exceed the wait timeout. The reasoning for that is based on Heroku router's behavior, that the request would be dropped anyway after the wait timeout. So, for example, with the default settings of `service_timeout=15`, `wait_timeout=30`, a request that had 20 seconds of wait time will not have a service timeout of 15, but instead of 10, as there are only 10 seconds left before `wait_timeout` is reached. This behavior can be disabled by setting `service_past_wait` to `true`. When set, the `service_timeout` setting will always be honored.
|
95
|
+
A request's computed wait time may affect the service timeout used for it. Basically, a request's wait time plus service time may not exceed the wait timeout. The reasoning for that is based on Heroku router's behavior, that the request would be dropped anyway after the wait timeout. So, for example, with the default settings of `service_timeout=15`, `wait_timeout=30`, a request that had 20 seconds of wait time will not have a service timeout of 15, but instead of 10, as there are only 10 seconds left before `wait_timeout` is reached. This behavior can be disabled by setting `service_past_wait` to `true`. When set, the `service_timeout` setting will always be honored. Please note that if you're using the `RACK_TIMEOUT_SERVICE_PAST_WAIT` environment variable, any value different than `"false"` will be considered `true`.
|
106
96
|
|
107
97
|
The way we're able to infer a request's start time, and from that its wait time, is through the availability of the `X-Request-Start` HTTP header, which is expected to contain the time since epoch in milliseconds. (A concession is made for nginx's sec.msec notation.)
|
108
98
|
|
@@ -137,8 +127,6 @@ At the moment rack-timeout does not try to address this issue. As a fail-safe ag
|
|
137
127
|
More detailed explanations of the issues surrounding timing out in ruby during IO blocks can be found at:
|
138
128
|
|
139
129
|
- http://redgetan.cc/understanding-timeouts-in-cruby/
|
140
|
-
- https://shellycloud.com/blog/2013/06/the-pesky-problem-of-freezing-thin
|
141
|
-
|
142
130
|
|
143
131
|
### Timing Out Inherently Unsafe
|
144
132
|
|
@@ -199,17 +187,17 @@ Errors
|
|
199
187
|
|
200
188
|
Rack::Timeout can raise three types of exceptions. They are:
|
201
189
|
|
202
|
-
Two descend from `Rack::Timeout::Error`, which itself descends from `RuntimeError` and is generally caught by an unqualified `
|
203
|
-
|
204
|
-
* `Rack::Timeout::RequestExpiryError`: this is raised when a request is skipped for being too old (see Wait Timeout section). This error cannot generally be rescued from inside a Rails controller action as it happens before the request has a chance to enter Rails.
|
205
|
-
|
206
|
-
This shouldn't be different for other frameworks, unless you have something above Rack::Timeout in the middleware stack, which you generally shouldn't.
|
190
|
+
Two descend from `Rack::Timeout::Error`, which itself descends from `RuntimeError` and is generally caught by an unqualified `rescue`. The third, `RequestTimeoutException`, is more complicated and the most important.
|
207
191
|
|
208
192
|
* `Rack::Timeout::RequestTimeoutException`: this is raised when a request has run for longer than the specified timeout. This descends from `Exception`, not from `Rack::Timeout::Error` (it has to be rescued from explicitly). It's raised by the rack-timeout timer thread in the application thread, at the point in the stack the app happens to be in when the timeout is triggered. This exception could be caught explicitly within the application, but in doing so you're working past the timeout. This is ok for quick cleanup work but shouldn't be abused as Rack::Timeout will not kick in twice for the same request.
|
209
193
|
|
210
194
|
Rails will generally intercept `Exception`s, but in plain Rack apps, this exception will be caught by rack-timeout and re-raised as a `Rack::Timeout::RequestTimeoutError`. This is to prevent an `Exception` from bubbling up beyond rack-timeout and to the server.
|
211
195
|
|
212
|
-
* `Rack::Timeout::RequestTimeoutError`
|
196
|
+
* `Rack::Timeout::RequestTimeoutError` descends from `Rack::Timeout::Error`, but it's only really seen in the case described above. It'll not be seen in a standard Rails app, and will only be seen in Sinatra if rescuing from exceptions is disabled.
|
197
|
+
|
198
|
+
* `Rack::Timeout::RequestExpiryError`: this is raised when a request is skipped for being too old (see Wait Timeout section). This error cannot generally be rescued from inside a Rails controller action as it happens before the request has a chance to enter Rails.
|
199
|
+
|
200
|
+
This shouldn't be different for other frameworks, unless you have something above Rack::Timeout in the middleware stack, which you generally shouldn't.
|
213
201
|
|
214
202
|
You shouldn't rescue from these errors for reporting purposes. Instead, you can subscribe for state change notifications with observers.
|
215
203
|
|
@@ -224,22 +212,32 @@ If you're trying to test that a `Rack::Timeout::RequestTimeoutException` is rais
|
|
224
212
|
|
225
213
|
Because rack-timeout may raise at any point in the codepath of a timed-out request, the stack traces for similar requests may differ, causing rollbar to create separate entries for each timeout.
|
226
214
|
|
227
|
-
|
215
|
+
The recommended practice is to configure [Custom Fingerprints][rollbar-customfingerprint] on Rollbar.
|
228
216
|
|
229
|
-
|
217
|
+
[rollbar-customfingerprint]: https://docs.rollbar.com/docs/custom-grouping/
|
230
218
|
|
231
|
-
|
232
|
-
require "rack/timeout/rollbar"
|
219
|
+
Example:
|
233
220
|
|
234
|
-
|
221
|
+
```json
|
222
|
+
[
|
223
|
+
{
|
224
|
+
"condition": {
|
225
|
+
"eq": "Rack::Timeout::RequestTimeoutException",
|
226
|
+
"path": "body.trace.exception.class"
|
227
|
+
},
|
228
|
+
"fingerprint": "Rack::Timeout::RequestTimeoutException {{context}}",
|
229
|
+
"title": "Rack::Timeout::RequestTimeoutException {{context}}"
|
230
|
+
}
|
231
|
+
]
|
235
232
|
|
236
|
-
|
233
|
+
```
|
237
234
|
|
238
|
-
|
239
|
-
|
240
|
-
end
|
235
|
+
This configuration will generate exceptions following the pattern: `Rack::Timeout::RequestTimeoutException controller#action
|
236
|
+
`
|
241
237
|
|
238
|
+
On previous versions this configuration was made using `Rack::Timeout::Rollbar` which was removed. [More details on the Issue #122][rollbar-removal-issue].
|
242
239
|
|
240
|
+
[rollbar-removal-issue]: https://github.com/heroku/rack-timeout/issues/122
|
243
241
|
|
244
242
|
Observers
|
245
243
|
---------
|
@@ -315,5 +313,5 @@ This version of Rack::Timeout is compatible with Ruby 2.1 and up, and, for Rails
|
|
315
313
|
|
316
314
|
|
317
315
|
---
|
318
|
-
Copyright © 2010-2016 Caio Chassot, released under the MIT license
|
316
|
+
Copyright © 2010-2016 Caio Chassot, released under the MIT license
|
319
317
|
<http://github.com/heroku/rack-timeout>
|
data/Rakefile
ADDED
data/lib/rack/timeout/core.rb
CHANGED
@@ -3,7 +3,6 @@ require "securerandom"
|
|
3
3
|
require_relative "support/monotonic_time"
|
4
4
|
require_relative "support/scheduler"
|
5
5
|
require_relative "support/timeout"
|
6
|
-
require_relative "legacy"
|
7
6
|
|
8
7
|
module Rack
|
9
8
|
class Timeout
|
@@ -43,7 +42,9 @@ module Rack
|
|
43
42
|
:timed_out, # This request has run for too long and we're raising a timeout error in it
|
44
43
|
:completed, # We're done with this request (also set after having timed out a request)
|
45
44
|
]
|
46
|
-
ENV_INFO_KEY = "rack-timeout.info" # key under which each request's RequestDetails instance is stored in its env.
|
45
|
+
ENV_INFO_KEY = "rack-timeout.info".freeze # key under which each request's RequestDetails instance is stored in its env.
|
46
|
+
HTTP_X_REQUEST_ID = "HTTP_X_REQUEST_ID".freeze # key where request id is stored if generated by upstream client/proxy
|
47
|
+
ACTION_DISPATCH_REQUEST_ID = "action_dispatch.request_id".freeze # key where request id is stored if generated by action dispatch
|
47
48
|
|
48
49
|
# helper methods to read timeout properties. Ensure they're always positive numbers or false. When set to false (or 0), their behaviour is disabled.
|
49
50
|
def read_timeout_property value, default
|
@@ -63,11 +64,11 @@ module Rack
|
|
63
64
|
:wait_overtime, # Additional time over @wait_timeout for requests with a body, like POST requests. These may take longer to be received by the server before being passed down to the application, but should not be expired.
|
64
65
|
:service_past_wait # when false, reduces the request's computed timeout from the service_timeout value if the complete request lifetime (wait + service) would have been longer than wait_timeout (+ wait_overtime when applicable). When true, always uses the service_timeout value. we default to false under the assumption that the router would drop a request that's not responded within wait_timeout, thus being there no point in servicing beyond seconds_service_left (see code further down) up until service_timeout.
|
65
66
|
|
66
|
-
def initialize(app, service_timeout:nil, wait_timeout:nil, wait_overtime:nil, service_past_wait:
|
67
|
-
@service_timeout = read_timeout_property service_timeout, 15
|
68
|
-
@wait_timeout = read_timeout_property wait_timeout, 30
|
69
|
-
@wait_overtime = read_timeout_property wait_overtime, 60
|
70
|
-
@service_past_wait = service_past_wait
|
67
|
+
def initialize(app, service_timeout:nil, wait_timeout:nil, wait_overtime:nil, service_past_wait:"not_specified")
|
68
|
+
@service_timeout = read_timeout_property service_timeout, ENV.fetch("RACK_TIMEOUT_SERVICE_TIMEOUT", 15).to_i
|
69
|
+
@wait_timeout = read_timeout_property wait_timeout, ENV.fetch("RACK_TIMEOUT_WAIT_TIMEOUT", 30).to_i
|
70
|
+
@wait_overtime = read_timeout_property wait_overtime, ENV.fetch("RACK_TIMEOUT_WAIT_OVERTIME", 60).to_i
|
71
|
+
@service_past_wait = service_past_wait == "not_specified" ? ENV.fetch("RACK_TIMEOUT_SERVICE_PAST_WAIT", false).to_s != "false" : service_past_wait
|
71
72
|
@app = app
|
72
73
|
end
|
73
74
|
|
@@ -75,7 +76,7 @@ module Rack
|
|
75
76
|
RT = self # shorthand reference
|
76
77
|
def call(env)
|
77
78
|
info = (env[ENV_INFO_KEY] ||= RequestDetails.new)
|
78
|
-
info.id ||= env[
|
79
|
+
info.id ||= env[HTTP_X_REQUEST_ID] || env[ACTION_DISPATCH_REQUEST_ID] || SecureRandom.uuid
|
79
80
|
|
80
81
|
time_started_service = Time.now # The wall time the request started being processed by rack
|
81
82
|
ts_started_service = fsecs # The monotonic time the request started being processed by rack
|
data/lib/rack/timeout/rails.rb
CHANGED
@@ -3,6 +3,11 @@ require_relative "base"
|
|
3
3
|
class Rack::Timeout::Railtie < Rails::Railtie
|
4
4
|
initializer("rack-timeout.prepend") do |app|
|
5
5
|
next if Rails.env.test?
|
6
|
-
|
6
|
+
|
7
|
+
if defined?(ActionDispatch::RequestId)
|
8
|
+
app.config.middleware.insert_after(ActionDispatch::RequestId, Rack::Timeout)
|
9
|
+
else
|
10
|
+
app.config.middleware.insert_before(Rack::Runtime, Rack::Timeout)
|
11
|
+
end
|
7
12
|
end
|
8
|
-
end
|
13
|
+
end
|
data/lib/rack/timeout/rollbar.rb
CHANGED
@@ -1,53 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Groups timeout exceptions in rollbar by exception class, http method, and url.
|
4
|
-
#
|
5
|
-
# Usage: after requiring rollbar (say, in your rollbar initializer file), call:
|
6
|
-
#
|
7
|
-
# require "rack/timeout/rollbar"
|
8
|
-
#
|
9
|
-
# Ruby 2.1 is required as we use `Module.prepend`.
|
10
|
-
#
|
11
|
-
# To use a custom fingerprint for grouping:
|
12
|
-
#
|
13
|
-
# Rack::Timeout::Rollbar.fingerprint do |exception, env|
|
14
|
-
# # … return some kind of string derived from exception and env
|
15
|
-
# end
|
16
|
-
|
17
|
-
module Rack::Timeout::Rollbar
|
18
|
-
|
19
|
-
def self.fingerprint(&block)
|
20
|
-
define_method(:rack_timeout_fingerprint) { |exception, env| block[exception, env] }
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.default_rack_timeout_fingerprint(exception, env)
|
24
|
-
request = ::Rack::Request.new(env)
|
25
|
-
[ exception.class.name,
|
26
|
-
request.request_method,
|
27
|
-
request.path
|
28
|
-
].join(" ")
|
29
|
-
end
|
30
|
-
|
31
|
-
fingerprint &method(:default_rack_timeout_fingerprint)
|
32
|
-
|
33
|
-
|
34
|
-
def build_payload(level, message, exception, extra)
|
35
|
-
payload = super(level, message, exception, extra)
|
36
|
-
|
37
|
-
return payload unless exception.is_a?(::Rack::Timeout::ExceptionWithEnv) \
|
38
|
-
&& payload.respond_to?(:[]) \
|
39
|
-
&& payload.respond_to?(:[]=)
|
40
|
-
|
41
|
-
data = payload["data"]
|
42
|
-
return payload unless data.respond_to?(:[]=)
|
43
|
-
|
44
|
-
payload = payload.dup
|
45
|
-
data = data.dup
|
46
|
-
data["fingerprint"] = rack_timeout_fingerprint(exception, exception.env)
|
47
|
-
payload["data"] = data
|
48
|
-
|
49
|
-
return payload
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
::Rollbar::Notifier.prepend ::Rack::Timeout::Rollbar
|
1
|
+
warn 'DEPRECATION WARNING: The Rollbar module was removed from rack-timeout. For more details check the README on heroku/rack-timeout'
|
@@ -21,6 +21,11 @@ class Rack::Timeout::Scheduler
|
|
21
21
|
|
22
22
|
# stores a proc to run later, and the time it should run at
|
23
23
|
class RunEvent < Struct.new(:monotime, :proc)
|
24
|
+
def initialize(*args)
|
25
|
+
@cancelled = false
|
26
|
+
super(*args)
|
27
|
+
end
|
28
|
+
|
24
29
|
def cancel!
|
25
30
|
@cancelled = true
|
26
31
|
end
|
@@ -51,6 +56,7 @@ class Rack::Timeout::Scheduler
|
|
51
56
|
end
|
52
57
|
|
53
58
|
def initialize
|
59
|
+
@runner = nil
|
54
60
|
@events = [] # array of `RunEvent`s
|
55
61
|
@mx_events = Mutex.new # mutex to change said array
|
56
62
|
@mx_runner = Mutex.new # mutex for creating a runner thread
|
data/test/basic_test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "rack/test"
|
3
|
+
require "rack-timeout"
|
4
|
+
|
5
|
+
class BasicTest < Test::Unit::TestCase
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
Rack::Builder.new do
|
10
|
+
use Rack::Timeout, service_timeout: 1
|
11
|
+
|
12
|
+
map "/" do
|
13
|
+
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
|
14
|
+
end
|
15
|
+
|
16
|
+
map "/sleep" do
|
17
|
+
run lambda { |env| sleep }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_ok
|
23
|
+
get "/"
|
24
|
+
assert last_response.ok?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_timeout
|
28
|
+
assert_raises(Rack::Timeout::RequestTimeoutError) do
|
29
|
+
get "/sleep"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-timeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Chassot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2018-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack-test
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
description: Rack middleware which aborts requests that have been running for longer
|
14
56
|
than a specified timeout.
|
15
57
|
email: caio@heroku.com
|
@@ -18,12 +60,13 @@ extensions: []
|
|
18
60
|
extra_rdoc_files: []
|
19
61
|
files:
|
20
62
|
- CHANGELOG
|
63
|
+
- Gemfile
|
21
64
|
- MIT-LICENSE
|
22
65
|
- README.markdown
|
66
|
+
- Rakefile
|
23
67
|
- lib/rack-timeout.rb
|
24
68
|
- lib/rack/timeout/base.rb
|
25
69
|
- lib/rack/timeout/core.rb
|
26
|
-
- lib/rack/timeout/legacy.rb
|
27
70
|
- lib/rack/timeout/logger.rb
|
28
71
|
- lib/rack/timeout/logging-observer.rb
|
29
72
|
- lib/rack/timeout/rails.rb
|
@@ -32,6 +75,7 @@ files:
|
|
32
75
|
- lib/rack/timeout/support/namespace.rb
|
33
76
|
- lib/rack/timeout/support/scheduler.rb
|
34
77
|
- lib/rack/timeout/support/timeout.rb
|
78
|
+
- test/basic_test.rb
|
35
79
|
homepage: http://github.com/heroku/rack-timeout
|
36
80
|
licenses:
|
37
81
|
- MIT
|
@@ -52,9 +96,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
96
|
version: '0'
|
53
97
|
requirements: []
|
54
98
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.5.1
|
99
|
+
rubygems_version: 2.5.2.1
|
56
100
|
signing_key:
|
57
101
|
specification_version: 4
|
58
102
|
summary: Abort requests that are taking too long
|
59
|
-
test_files:
|
60
|
-
|
103
|
+
test_files:
|
104
|
+
- test/basic_test.rb
|
105
|
+
- Gemfile
|
106
|
+
- Rakefile
|
data/lib/rack/timeout/legacy.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require_relative "support/namespace"
|
2
|
-
|
3
|
-
|
4
|
-
# This provides compatibility with versions <= 0.3.x where timeout settings were class-level.
|
5
|
-
# Beware that, unintuitively, a class-level setting overrides local settings for all instances.
|
6
|
-
# Generally speaking, everyone should migrate to instance-level settings.
|
7
|
-
|
8
|
-
module Rack::Timeout::ClassLevelProperties
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
attr_accessor :service_timeout, :wait_timeout, :wait_overtime, :service_past_wait
|
12
|
-
alias_method :timeout=, :service_timeout=
|
13
|
-
|
14
|
-
[ :service_timeout=,
|
15
|
-
:timeout=,
|
16
|
-
:wait_timeout=,
|
17
|
-
:wait_overtime=,
|
18
|
-
:service_past_wait=,
|
19
|
-
].each do |isetter|
|
20
|
-
setter = instance_method(isetter)
|
21
|
-
define_method(isetter) do |x|
|
22
|
-
defined?(Rails) or warn "`Rack::Timeout.#{isetter}`: class-level settings are deprecated. See README for examples on using the middleware initializer instead."
|
23
|
-
setter.bind(self).call(x)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
module InstanceMethods
|
29
|
-
|
30
|
-
[:service_timeout, :wait_timeout, :wait_overtime].each do |m|
|
31
|
-
define_method(m) { read_timeout_property self.class.send(m), super() }
|
32
|
-
end
|
33
|
-
|
34
|
-
def service_past_wait
|
35
|
-
self.class.service_past_wait || super
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
Rack::Timeout.extend Rack::Timeout::ClassLevelProperties::ClassMethods
|
43
|
-
Rack::Timeout.send :prepend, Rack::Timeout::ClassLevelProperties::InstanceMethods
|