rack-timeout 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright © 2010 Caio Chassot
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,40 @@
1
+ Rack::Timeout
2
+ =============
3
+
4
+ Abort requests that are taking too long.
5
+
6
+
7
+ Usage
8
+ -----
9
+
10
+ ### Rails 3 app or Rails 2.3 app with Bundler
11
+
12
+ # Gemfile
13
+ gem "system_timer" if RUBY_VERSION < "1.9"
14
+ gem "rack-timeout"
15
+
16
+
17
+ ### Rails 2.3 app without Bundler
18
+
19
+ # config/environment.rb
20
+ config.gem "system_timer" if RUBY_VERSION < "1.9"
21
+ config.gem "rack-timeout"
22
+
23
+
24
+ ### Sinatra and other Rack apps
25
+
26
+ # config.ru
27
+ require 'rack/timeout'
28
+ use Rack::Timeout
29
+ Rack::Timeout.timeout = 10 # this line is optional. if omitted, default is 30 seconds.
30
+
31
+
32
+ ### Setting a custom timeout for Rails apps:
33
+
34
+ # config/initializers/timeout.rb
35
+ Rack::Timeout.timeout = 10 # seconds
36
+
37
+
38
+ ---
39
+ Copyright © 2010 Caio Chassot, released under the MIT license
40
+ <http://github.com/kch/rack-timeout>
@@ -0,0 +1,20 @@
1
+ require RUBY_VERSION < '1.9' ? 'system_timer' : 'timeout'
2
+ SystemTimer ||= Timeout
3
+
4
+ module Rack
5
+ class Timeout
6
+ @timeout = 30
7
+ class << self
8
+ attr_accessor :timeout
9
+ end
10
+
11
+ def initialize(app)
12
+ @app = app
13
+ end
14
+
15
+ def call(env)
16
+ SystemTimer.timeout(self.class.timeout) { @app.call(env) }
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'rack/timeout')
2
+
3
+ if defined? Rails
4
+ case Rails::VERSION::MAJOR
5
+ when 2; Rails.configuration.middleware.use Rack::Timeout
6
+ when 3
7
+ class Rack::Timeout::Railtie < Rails::Railtie
8
+ initializer("rack-timeout.insert-rack-timeout") { |app| app.config.middleware.use Rack::Timeout }
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-timeout
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Caio Chassot
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-29 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: dev@caiochassot.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - MIT-LICENSE
31
+ - README.markdown
32
+ - lib/rack/timeout.rb
33
+ - lib/rack-timeout.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/kch/rack-timeout
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Abort requests that are taking too long
66
+ test_files: []
67
+