rack-timeout 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/timeout.rb +6 -2
- data/lib/rack/timeout/logger.rb +5 -10
- 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: 738562ce41045bc02a6cdf9ffb7333c6bdd73247
|
4
|
+
data.tar.gz: c665463483d072eda397c6ad9056d3ba2073f7ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffefe99a1089a25cd504cd88e3dbc4bf4a834bf08b982ad97aa09057ba5e03871f38e5ed36bf65ba256a1f7456e429858ff6a796bee3a90069c9dc0e3dbb38c9
|
7
|
+
data.tar.gz: 1b6e1b54a34fa911e21bfdefefde66f3d74c75a590cb42642cf9bdc512bdb5558ef987815f7943edf069567fb7574f7c982ef87c09ca5fb28101c3ab4ef03742
|
data/lib/rack/timeout.rb
CHANGED
@@ -13,7 +13,11 @@ module Rack
|
|
13
13
|
:service, # time rack spent processing the request (updated ~ every second)
|
14
14
|
:timeout, # the actual computed timeout to be used for this request
|
15
15
|
:state, # the request's current state, see below:
|
16
|
-
|
16
|
+
) {
|
17
|
+
def ms(k) # helper method used for formatting values in milliseconds
|
18
|
+
'%.fms' % (self[k] * 1000) if self[k]
|
19
|
+
end
|
20
|
+
}
|
17
21
|
VALID_STATES = [
|
18
22
|
:expired, # The request was too old by the time it reached rack (see wait_timeout, wait_overtime)
|
19
23
|
:ready, # We're about to start processing this request
|
@@ -99,7 +103,7 @@ module Rack
|
|
99
103
|
sleep(sleep_seconds)
|
100
104
|
end
|
101
105
|
RT._set_state! env, :timed_out
|
102
|
-
app_thread.raise(RequestTimeoutError, "Request ran for longer than #{info.timeout}
|
106
|
+
app_thread.raise(RequestTimeoutError, "Request #{"waited #{info.ms(:wait)} seconds, then " if info.wait}ran for longer than #{info.ms(:timeout)}")
|
103
107
|
end
|
104
108
|
response = @app.call(env)
|
105
109
|
ensure
|
data/lib/rack/timeout/logger.rb
CHANGED
@@ -39,22 +39,17 @@ class Rack::Timeout
|
|
39
39
|
(@fallback_logger ||= self.class.mk_logger($stderr))
|
40
40
|
end
|
41
41
|
|
42
|
-
# helper method used for formatting in #log_state_change
|
43
|
-
def ms(s)
|
44
|
-
'%.fms' % (s * 1000)
|
45
|
-
end
|
46
|
-
|
47
42
|
# generates the actual log string
|
48
43
|
def log_state_change(env)
|
49
44
|
info = env[ENV_INFO_KEY]
|
50
45
|
level = STATE_LOG_LEVEL[info.state]
|
51
46
|
logger(env).send(level) do
|
52
47
|
s = 'source=rack-timeout'
|
53
|
-
s << ' id=' << info.id
|
54
|
-
s << ' wait=' << ms(
|
55
|
-
s << ' timeout=' << ms(
|
56
|
-
s << ' service=' << ms(
|
57
|
-
s << ' state=' << info.state.to_s
|
48
|
+
s << ' id=' << info.id if info.id
|
49
|
+
s << ' wait=' << info.ms(:wait) if info.wait
|
50
|
+
s << ' timeout=' << info.ms(:timeout) if info.timeout
|
51
|
+
s << ' service=' << info.ms(:service) if info.service
|
52
|
+
s << ' state=' << info.state.to_s if info.state
|
58
53
|
s
|
59
54
|
end
|
60
55
|
end
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Chassot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-21 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.
|