rack-timeout 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +11 -5
- data/lib/rack/timeout.rb +2 -2
- metadata +3 -3
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Rack::Timeout
|
2
2
|
=============
|
3
3
|
|
4
|
-
Abort requests that are taking too long.
|
4
|
+
Abort requests that are taking too long; a Timeout::Error will be raised.
|
5
5
|
|
6
6
|
|
7
7
|
Usage
|
@@ -10,14 +10,14 @@ Usage
|
|
10
10
|
### Rails 3 app or Rails 2.3 app with Bundler
|
11
11
|
|
12
12
|
# Gemfile
|
13
|
-
gem "
|
13
|
+
gem "SystemTimer", :require => "system_timer", :platforms => :ruby_18
|
14
14
|
gem "rack-timeout"
|
15
15
|
|
16
16
|
|
17
17
|
### Rails 2.3 app without Bundler
|
18
18
|
|
19
19
|
# config/environment.rb
|
20
|
-
config.gem "system_timer" if RUBY_VERSION < "1.9"
|
20
|
+
config.gem "SystemTimer", :require => "system_timer" if RUBY_VERSION < "1.9"
|
21
21
|
config.gem "rack-timeout"
|
22
22
|
|
23
23
|
|
@@ -26,15 +26,21 @@ Usage
|
|
26
26
|
# config.ru
|
27
27
|
require 'rack/timeout'
|
28
28
|
use Rack::Timeout
|
29
|
-
Rack::Timeout.timeout = 10 # this line is optional. if omitted, default is
|
29
|
+
Rack::Timeout.timeout = 10 # this line is optional. if omitted, default is 15 seconds.
|
30
30
|
|
31
31
|
|
32
|
-
### Setting a custom timeout for Rails apps
|
32
|
+
### Setting a custom timeout for Rails apps
|
33
33
|
|
34
34
|
# config/initializers/timeout.rb
|
35
35
|
Rack::Timeout.timeout = 10 # seconds
|
36
36
|
|
37
37
|
|
38
|
+
### Here be dragons
|
39
|
+
|
40
|
+
SystemTimer/timeout rely on threads. If your app or any of the libraries it depends on is
|
41
|
+
not thread-safe, you may run into issues using rack-timeout.
|
42
|
+
|
43
|
+
|
38
44
|
---
|
39
45
|
Copyright © 2010 Caio Chassot, released under the MIT license
|
40
46
|
<http://github.com/kch/rack-timeout>
|
data/lib/rack/timeout.rb
CHANGED
@@ -3,7 +3,7 @@ SystemTimer ||= Timeout
|
|
3
3
|
|
4
4
|
module Rack
|
5
5
|
class Timeout
|
6
|
-
@timeout =
|
6
|
+
@timeout = 15
|
7
7
|
class << self
|
8
8
|
attr_accessor :timeout
|
9
9
|
end
|
@@ -13,7 +13,7 @@ module Rack
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
16
|
-
SystemTimer.timeout(self.class.timeout) { @app.call(env) }
|
16
|
+
SystemTimer.timeout(self.class.timeout, ::Timeout::Error) { @app.call(env) }
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Caio Chassot
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-07-13 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|