kronk 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 1.9.2 / 2012-05-23
2
+
3
+ * Bugfixes:
4
+
5
+ * Ensure HTTP response body is read before feeding to the pool.
6
+
1
7
  === 1.9.1 / 2012-05-22
2
8
 
3
9
  * Enhancements:
@@ -14,7 +14,7 @@ require 'yaml'
14
14
  class Kronk
15
15
 
16
16
  # This gem's version.
17
- VERSION = '1.9.1'
17
+ VERSION = '1.9.2'
18
18
 
19
19
  require 'kronk/constants'
20
20
  require 'kronk/queue_runner'
@@ -198,6 +198,7 @@ class Kronk
198
198
  D 'Conn socket closed'
199
199
  elsif keep_alive?(req, res)
200
200
  D 'Conn keep-alive'
201
+ res.body
201
202
  add_to_pool
202
203
  elsif not res.body and @close_on_empty_response
203
204
  D 'Conn close'
@@ -77,6 +77,15 @@ class Kronk
77
77
  @paths[uri][0] = (@paths[uri][0] * @paths[uri][1] + time) / pcount
78
78
  @paths[uri][0] = @paths[uri][0].round @precision
79
79
  @paths[uri][1] = pcount
80
+
81
+ clean_req_log
82
+ end
83
+
84
+
85
+ def clean_req_log
86
+ if @paths.length > 500
87
+ order_reqs[500..-1].each{|(uri, vals)| @paths.delete uri }
88
+ end
80
89
  end
81
90
 
82
91
 
@@ -148,8 +157,13 @@ class Kronk
148
157
  end
149
158
 
150
159
 
160
+ def order_reqs
161
+ @paths.to_a.sort{|x,y| y[1] <=> x[1]}
162
+ end
163
+
164
+
151
165
  def slowest_reqs
152
- @slowest_reqs ||= @paths.to_a.sort{|x,y| y[1] <=> x[1]}[0..9]
166
+ @slowest_reqs ||= order_reqs[0..9]
153
167
  end
154
168
 
155
169
 
@@ -262,10 +276,11 @@ Avg. Slowest Requests (ms, count)
262
276
 
263
277
 
264
278
  def render
265
- clear_screen if @interactive
266
- out = "#{head}#{body}\n"
267
- @line_count = out.to_s.split("\n").length
279
+ out = "#{head}#{body}\n"
280
+ new_count = out.to_s.split("\n").length
268
281
  @last_print = Time.now
282
+ clear_screen if @interactive
283
+ @line_count = new_count
269
284
  $stdout.print out
270
285
  $stdout.flush
271
286
  end
@@ -448,11 +448,7 @@ class Kronk
448
448
 
449
449
  @response = stream opts
450
450
 
451
- if block_given?
452
- block = lambda{|chunk| yield @response, chunk }
453
- end
454
-
455
- @response.body(&block) # make sure to read the full body from io
451
+ @response.body # make sure to read the full body from io
456
452
  @response.time = Time.now - start_time - @response.conn_time
457
453
 
458
454
  @response
@@ -468,7 +464,7 @@ class Kronk
468
464
  # Connection must be closed using:
469
465
  # request.connection.finish
470
466
 
471
- def stream opts={}
467
+ def stream opts={}, &block
472
468
  retried = false
473
469
 
474
470
  begin
@@ -477,7 +473,7 @@ class Kronk
477
473
  conn.start unless conn.started?
478
474
  conn_time = Time.now - start_time
479
475
 
480
- @response = conn.request http_request, nil, opts
476
+ @response = conn.request http_request, nil, opts, &block
481
477
  @response.conn_time = conn_time
482
478
  @response.request = self
483
479
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kronk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70132287844660 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70132287844660
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.5'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: cookiejar
27
- requirement: &70132287844220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 0.3.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70132287844220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: ruby-path
38
- requirement: &70132287843780 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 1.0.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70132287843780
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: mime-types
49
- requirement: &70132287843340 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.18.0
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70132287843340
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.18.0
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rdoc
60
- requirement: &70132287842900 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '3.10'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70132287842900
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.10'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: plist
71
- requirement: &70132287842460 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: 3.1.0
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70132287842460
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 3.1.0
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: nokogiri
82
- requirement: &70132287842020 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '1.4'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *70132287842020
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.4'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: mocha
93
- requirement: &70132287841540 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ~>
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: 0.9.12
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *70132287841540
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.9.12
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: hoe
104
- requirement: &70132287841020 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ~>
@@ -109,7 +149,12 @@ dependencies:
109
149
  version: '3.0'
110
150
  type: :development
111
151
  prerelease: false
112
- version_requirements: *70132287841020
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '3.0'
113
158
  description: ! 'Kronk is a command line swiss-army-knife for HTTP services.
114
159
 
115
160
 
@@ -217,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
262
  version: '0'
218
263
  requirements: []
219
264
  rubyforge_project: kronk
220
- rubygems_version: 1.8.11
265
+ rubygems_version: 1.8.18
221
266
  signing_key:
222
267
  specification_version: 3
223
268
  summary: Kronk is a command line swiss-army-knife for HTTP services