rack-timeout 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +9 -6
- data/lib/rack/timeout.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84c611398a87d61130bbda91d3b98407a42b5906
|
4
|
+
data.tar.gz: 824bf643c7817f626c4a1f523b346b41a30ea97c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9d4f5e73090c55c0656c1880a0cd36eda06e062bf24989fb6d9a8eba290ab708b6c8a66646864ba780e37b16b9f391a250b53bfa029834a409d2e29afe80ac0
|
7
|
+
data.tar.gz: 73b9e72dd731472638cbb330582b6b93bd958809de61167e41f3fb138f4559c147ad6cf79e1b1c36a9318e5017e07b1a45d47f2e8dfbb04724e436323cc6d94e
|
data/README.markdown
CHANGED
@@ -164,19 +164,22 @@ If you're trying to test that a `Rack::Timeout::RequestTimeoutError` is raised i
|
|
164
164
|
Observers
|
165
165
|
---------
|
166
166
|
|
167
|
-
Observers are
|
167
|
+
Observers are blocks that are notified about state changes during a request's lifetime. Keep in mind that the `active` state is set every ~1s, so you'll be notified every time.
|
168
168
|
|
169
|
-
You can register an observer
|
169
|
+
You can register an observer with:
|
170
170
|
|
171
171
|
Rack::Timeout.register_state_change_observer(:a_unique_name) { |env| do_things env }
|
172
172
|
|
173
|
-
|
173
|
+
There's currently no way to subscribe to changes into or out of a particular state. To check the actual state we're moving into, read `env['rack-timeout.info'].state`. Handling going out of a state would require some additional logic in the observer.
|
174
174
|
|
175
175
|
You can remove an observer with `unregister_state_change_observer`:
|
176
176
|
|
177
177
|
Rack::Timeout.unregister_state_change_observer(:a_unique_name)
|
178
178
|
|
179
|
-
|
179
|
+
|
180
|
+
rack-timeout's logging is implemented using an observer; see `Rack::Timeout::StageChangeLoggingObserver` in logger.rb for the implementation.
|
181
|
+
|
182
|
+
Custom observers might be used to do cleanup, store statistics on request length, timeouts, etc., and potentially do performance tuning on the fly.
|
180
183
|
|
181
184
|
|
182
185
|
Logging
|
@@ -184,9 +187,9 @@ Logging
|
|
184
187
|
|
185
188
|
Rack::Timeout logs a line every time there's a change in state in a request's lifetime.
|
186
189
|
|
187
|
-
|
190
|
+
Request state changes into `timed_out` and `expired` are logged at the `ERROR` level, most other things are logged as `INFO`. The `active` state is logged as `DEBUG`, every ~1s while the request is still active.
|
188
191
|
|
189
|
-
Rack::Timeout will try to use Rails.logger if present, otherwise it'll look for a logger in `env['rack.logger']`, and if neither are present, it'll create its own logger, either writing to `env['rack.errors']`, or to `$stderr` if the former is not set.
|
192
|
+
Rack::Timeout will try to use `Rails.logger` if present, otherwise it'll look for a logger in `env['rack.logger']`, and if neither are present, it'll create its own logger, either writing to `env['rack.errors']`, or to `$stderr` if the former is not set.
|
190
193
|
|
191
194
|
A custom logger can be set via `Rack::Timeout::StageChangeLoggingObserver.logger`. This takes priority over the automatic logger detection:
|
192
195
|
|
data/lib/rack/timeout.rb
CHANGED
@@ -29,7 +29,7 @@ module Rack
|
|
29
29
|
unless value == false || (value.is_a?(Numeric) && value >= 0)
|
30
30
|
raise ArgumentError, "value for #{property_name} should be false, zero, or a positive number."
|
31
31
|
end
|
32
|
-
value = false if value.zero? # zero means we're disabling the feature
|
32
|
+
value = false if value && value.zero? # zero means we're disabling the feature
|
33
33
|
instance_variable_set("@#{property_name}", value)
|
34
34
|
end
|
35
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-timeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Chassot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rack middleware which aborts requests that have been running for longer
|
14
14
|
than a specified timeout.
|