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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f4a3287d087373af78ba892d153244e803c4615
4
- data.tar.gz: 6111fecabc946f4537890bc63ec9e60f1dae757c
3
+ metadata.gz: 84c611398a87d61130bbda91d3b98407a42b5906
4
+ data.tar.gz: 824bf643c7817f626c4a1f523b346b41a30ea97c
5
5
  SHA512:
6
- metadata.gz: f609b6a82e645730dc47a945bcd2834424c4e1d68bfb1ff2f2462dcb2d1af36b77c8e7714da1df3ee00389c703101cd14484803c70c5d387a9f65d05803b0f3a
7
- data.tar.gz: b1a9caec46c8fa8b6832b2c265fa39c53d625806cac669b9705b0ea496e637aa5a982885d582377aed98a9c0fc38b7073280033bfc5b75cb601a8c0bddfcbbdf
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 objects or blocks that are notified about state changes during a request's lifetime.
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 easily with a block:
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
- This is how logging is implemented, too. See `Rack::Timeout::StageChangeLoggingObserver`.
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
- Custom observers might be used to store statistics on request length, timeouts, etc., and potentially do performance tuning on the fly.
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
- 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.
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.0
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-10-20 00:00:00.000000000 Z
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.