raindrops 0.13.0 → 0.19.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.document +1 -2
  3. data/.gitattributes +4 -0
  4. data/.gitignore +1 -1
  5. data/.olddoc.yml +13 -0
  6. data/GIT-VERSION-GEN +1 -1
  7. data/GNUmakefile +1 -2
  8. data/LICENSE +3 -3
  9. data/README +28 -34
  10. data/TODO +2 -0
  11. data/archive/.gitignore +3 -0
  12. data/archive/slrnpull.conf +4 -0
  13. data/examples/linux-listener-stats.rb +1 -2
  14. data/examples/watcher_demo.ru +1 -1
  15. data/examples/yahns.conf.rb +30 -0
  16. data/examples/zbatery.conf.rb +4 -1
  17. data/ext/raindrops/extconf.rb +107 -2
  18. data/ext/raindrops/linux_inet_diag.c +94 -101
  19. data/ext/raindrops/raindrops.c +28 -7
  20. data/ext/raindrops/tcp_info.c +245 -0
  21. data/lib/raindrops.rb +1 -1
  22. data/lib/raindrops/aggregate.rb +1 -1
  23. data/lib/raindrops/aggregate/last_data_recv.rb +1 -5
  24. data/lib/raindrops/aggregate/pmq.rb +23 -17
  25. data/lib/raindrops/linux.rb +5 -6
  26. data/lib/raindrops/middleware.rb +4 -6
  27. data/lib/raindrops/middleware/proxy.rb +2 -2
  28. data/lib/raindrops/watcher.rb +13 -13
  29. data/pkg.mk +26 -50
  30. data/raindrops.gemspec +14 -21
  31. data/test/ipv6_enabled.rb +4 -4
  32. data/test/test_aggregate_pmq.rb +1 -1
  33. data/test/test_inet_diag_socket.rb +1 -1
  34. data/test/test_last_data_recv_unicorn.rb +1 -1
  35. data/test/test_linux.rb +10 -2
  36. data/test/test_linux_all_tcp_listen_stats_leak.rb +2 -2
  37. data/test/test_linux_ipv6.rb +8 -0
  38. data/test/test_raindrops.rb +1 -1
  39. data/test/{test_linux_tcp_info.rb → test_tcp_info.rb} +34 -14
  40. data/test/test_watcher.rb +15 -10
  41. metadata +59 -171
  42. data/.wrongdoc.yml +0 -6
  43. data/Rakefile +0 -28
  44. data/ext/raindrops/linux_tcp_info.c +0 -173
@@ -37,7 +37,7 @@ def test_leak
37
37
  end
38
38
  cur_kb = rss_kb
39
39
  p [ :cur_kb, cur_kb ]
40
- ensure
41
- s.close
40
+ ensure
41
+ s.close
42
42
  end
43
43
  end if ENV["STRESS"].to_i != 0
@@ -12,6 +12,14 @@ class TestLinuxIPv6 < Test::Unit::TestCase
12
12
 
13
13
  TEST_ADDR = ENV["TEST_HOST6"] || "::1"
14
14
 
15
+ def setup
16
+ @to_close = []
17
+ end
18
+
19
+ def teardown
20
+ @to_close.each { |io| io.close unless io.closed? }
21
+ end
22
+
15
23
  def test_tcp
16
24
  s = TCPServer.new(TEST_ADDR, 0)
17
25
  port = s.addr[1]
@@ -134,7 +134,7 @@ def test_resize_mremap
134
134
  assert_equal 0, rd[rd.capa - 1]
135
135
  assert_equal 1, rd.incr(rd.capa - 1)
136
136
  assert_raises(ArgumentError) { rd[rd.capa] }
137
- rescue RangeError
137
+ rescue RangeError
138
138
  end # if RUBY_PLATFORM =~ /linux/
139
139
 
140
140
  def test_evaporate
@@ -5,15 +5,15 @@
5
5
  require 'socket'
6
6
  require 'pp'
7
7
  $stderr.sync = $stdout.sync = true
8
- class TestLinuxTCP_Info < Test::Unit::TestCase
8
+ class TestTCP_Info < Test::Unit::TestCase
9
9
 
10
10
  TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'
11
11
 
12
12
  # Linux kernel commit 5ee3afba88f5a79d0bff07ddd87af45919259f91
13
13
  TCP_INFO_useful_listenq = `uname -r`.strip >= '2.6.24'
14
14
 
15
-
16
- def test_tcp_server
15
+ def test_tcp_server_unacked
16
+ return if RUBY_PLATFORM !~ /linux/ # unacked not implemented on others...
17
17
  s = TCPServer.new(TEST_ADDR, 0)
18
18
  rv = Raindrops::TCP_Info.new s
19
19
  c = TCPSocket.new TEST_ADDR, s.addr[1]
@@ -29,10 +29,8 @@ def test_tcp_server
29
29
  tmp.get!(s)
30
30
  assert_equal before, tmp.object_id
31
31
 
32
- ensure
33
- c.close if c
34
- a.close if a
35
- s.close
32
+ ensure
33
+ [ c, a, s ].compact.each(&:close)
36
34
  end
37
35
 
38
36
  def test_accessors
@@ -42,12 +40,14 @@ def test_accessors
42
40
  assert tcp_info_methods.size >= 32
43
41
  tcp_info_methods.each do |m|
44
42
  next if m.to_sym == :get!
43
+ next if ! tmp.respond_to?(m)
45
44
  val = tmp.__send__ m
46
45
  assert_kind_of Integer, val
47
46
  assert val >= 0
48
47
  end
49
- ensure
50
- s.close
48
+ assert tmp.respond_to?(:state), 'every OS knows about TCP state, right?'
49
+ ensure
50
+ s.close
51
51
  end
52
52
 
53
53
  def test_tcp_server_delayed
@@ -60,9 +60,29 @@ def test_tcp_server_delayed
60
60
  a = s.accept
61
61
  i = Raindrops::TCP_Info.new(a)
62
62
  assert i.last_data_recv >= delay_ms, "#{i.last_data_recv} < #{delay_ms}"
63
- ensure
64
- c.close if c
65
- a.close if a
66
- s.close
63
+ ensure
64
+ c.close if c
65
+ a.close if a
66
+ s.close
67
+ end
68
+
69
+ def test_tcp_server_state_closed
70
+ s = TCPServer.new(TEST_ADDR, 0)
71
+ c = TCPSocket.new(TEST_ADDR, s.addr[1])
72
+ i = Raindrops::TCP_Info.allocate
73
+ a = s.accept
74
+ i.get!(a)
75
+ state = i.state
76
+ if Raindrops.const_defined?(:TCP)
77
+ assert_equal state, Raindrops::TCP[:ESTABLISHED]
78
+ end
79
+ c = c.close
80
+ sleep(0.01) # wait for kernel to update state
81
+ i.get!(a)
82
+ assert_not_equal state, i.state
83
+ ensure
84
+ s.close if s
85
+ c.close if c
86
+ a.close if a
67
87
  end
68
- end if RUBY_PLATFORM =~ /linux/
88
+ end if defined? Raindrops::TCP_Info
data/test/test_watcher.rb CHANGED
@@ -2,6 +2,11 @@
2
2
  require "test/unit"
3
3
  require "rack"
4
4
  require "raindrops"
5
+ begin
6
+ require 'aggregate'
7
+ rescue LoadError => e
8
+ warn "W: #{e} skipping #{__FILE__}"
9
+ end
5
10
 
6
11
  class TestWatcher < Test::Unit::TestCase
7
12
  TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'
@@ -113,28 +118,28 @@ def test_tail_queued_min
113
118
 
114
119
  def test_x_current_header
115
120
  env = @req.class.env_for "/active/#@addr.txt"
116
- status, headers, body = @app.call(env)
121
+ _status, headers, _body = @app.call(env)
117
122
  assert_equal "0", headers["X-Current"], headers.inspect
118
123
 
119
124
  env = @req.class.env_for "/queued/#@addr.txt"
120
- status, headers, body = @app.call(env)
125
+ _status, headers, _body = @app.call(env)
121
126
  assert_equal "1", headers["X-Current"], headers.inspect
122
127
 
123
128
  @ios << @srv.accept
124
129
  sleep 0.1
125
130
 
126
131
  env = @req.class.env_for "/queued/#@addr.txt"
127
- status, headers, body = @app.call(env)
132
+ _status, headers, _body = @app.call(env)
128
133
  assert_equal "0", headers["X-Current"], headers.inspect
129
134
 
130
135
  env = @req.class.env_for "/active/#@addr.txt"
131
- status, headers, body = @app.call(env)
136
+ _status, headers, _body = @app.call(env)
132
137
  assert_equal "1", headers["X-Current"], headers.inspect
133
138
  end
134
139
 
135
140
  def test_peaks
136
141
  env = @req.class.env_for "/active/#@addr.txt"
137
- status, headers, body = @app.call(env.dup)
142
+ _status, headers, _body = @app.call(env.dup)
138
143
  start = headers["X-First-Peak-At"]
139
144
  assert headers["X-First-Peak-At"], headers.inspect
140
145
  assert headers["X-Last-Peak-At"], headers.inspect
@@ -143,14 +148,14 @@ def test_peaks
143
148
  before = headers["X-Last-Peak-At"]
144
149
 
145
150
  env = @req.class.env_for "/queued/#@addr.txt"
146
- status, headers, body = @app.call(env)
151
+ _status, headers, _body = @app.call(env)
147
152
  assert_nothing_raised { Time.parse(headers["X-First-Peak-At"]) }
148
153
  assert_nothing_raised { Time.parse(headers["X-Last-Peak-At"]) }
149
154
  assert_equal before, headers["X-Last-Peak-At"], "should not change"
150
155
 
151
156
  sleep 2
152
157
  env = @req.class.env_for "/active/#@addr.txt"
153
- status, headers, body = @app.call(env.dup)
158
+ _status, headers, _body = @app.call(env.dup)
154
159
  assert_equal before, headers["X-Last-Peak-At"], headers.inspect
155
160
 
156
161
  @ios << @srv.accept
@@ -162,7 +167,7 @@ def test_peaks
162
167
  end
163
168
  sleep 0.1
164
169
  env = @req.class.env_for "/queued/#@addr.txt"
165
- status, headers, body = @app.call(env.dup)
170
+ _status, headers, _body = @app.call(env.dup)
166
171
  assert headers["X-Last-Peak-At"], headers.inspect
167
172
  assert_nothing_raised { Time.parse(headers["X-Last-Peak-At"]) }
168
173
  assert before != headers["X-Last-Peak-At"]
@@ -172,10 +177,10 @@ def test_peaks
172
177
  sleep 2
173
178
 
174
179
  env = @req.class.env_for "/queued/#@addr.txt"
175
- status, headers, body = @app.call(env)
180
+ _status, headers, _body = @app.call(env)
176
181
  assert_equal "0", headers["X-Current"]
177
182
  assert_nothing_raised { Time.parse(headers["X-Last-Peak-At"]) }
178
183
  assert_equal queued_before, headers["X-Last-Peak-At"], "should not change"
179
184
  assert_equal start, headers["X-First-Peak-At"]
180
185
  end
181
- end if RUBY_PLATFORM =~ /linux/
186
+ end if RUBY_PLATFORM =~ /linux/ && defined?(Aggregate)
metadata CHANGED
@@ -1,207 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
- name: !binary |-
3
- cmFpbmRyb3Bz
2
+ name: raindrops
4
3
  version: !ruby/object:Gem::Version
5
- version: 0.13.0
6
- prerelease:
4
+ version: 0.19.2
7
5
  platform: ruby
8
6
  authors:
9
- - !binary |-
10
- cmFpbmRyb3BzIGhhY2tlcnM=
7
+ - raindrops hackers
11
8
  autorequire:
12
9
  bindir: bin
13
10
  cert_chain: []
14
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2021-05-25 00:00:00.000000000 Z
15
12
  dependencies:
16
13
  - !ruby/object:Gem::Dependency
17
- name: !binary |-
18
- YWdncmVnYXRl
14
+ name: aggregate
19
15
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
16
  requirements:
22
- - - !binary |-
23
- fj4=
17
+ - - "~>"
24
18
  - !ruby/object:Gem::Version
25
- version: !binary |-
26
- MC4y
19
+ version: '0.2'
27
20
  type: :development
28
21
  prerelease: false
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
- none: false
31
23
  requirements:
32
- - - !binary |-
33
- fj4=
24
+ - - "~>"
34
25
  - !ruby/object:Gem::Version
35
- version: !binary |-
36
- MC4y
26
+ version: '0.2'
37
27
  - !ruby/object:Gem::Dependency
38
- name: !binary |-
39
- aW8tZXh0cmE=
28
+ name: test-unit
40
29
  requirement: !ruby/object:Gem::Requirement
41
- none: false
42
30
  requirements:
43
- - - !binary |-
44
- fj4=
31
+ - - "~>"
45
32
  - !ruby/object:Gem::Version
46
- version: !binary |-
47
- MS4y
48
- - - !binary |-
49
- Pj0=
50
- - !ruby/object:Gem::Version
51
- version: !binary |-
52
- MS4yLjM=
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - !binary |-
59
- fj4=
60
- - !ruby/object:Gem::Version
61
- version: !binary |-
62
- MS4y
63
- - - !binary |-
64
- Pj0=
65
- - !ruby/object:Gem::Version
66
- version: !binary |-
67
- MS4yLjM=
68
- - !ruby/object:Gem::Dependency
69
- name: !binary |-
70
- cG9zaXhfbXE=
71
- requirement: !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - !binary |-
75
- fj4=
76
- - !ruby/object:Gem::Version
77
- version: !binary |-
78
- Mi4w
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - !binary |-
85
- fj4=
86
- - !ruby/object:Gem::Version
87
- version: !binary |-
88
- Mi4w
89
- - !ruby/object:Gem::Dependency
90
- name: !binary |-
91
- cmFjaw==
92
- requirement: !ruby/object:Gem::Requirement
93
- none: false
94
- requirements:
95
- - - !binary |-
96
- fj4=
97
- - !ruby/object:Gem::Version
98
- version: !binary |-
99
- MS4y
33
+ version: '3.0'
100
34
  type: :development
101
35
  prerelease: false
102
36
  version_requirements: !ruby/object:Gem::Requirement
103
- none: false
104
37
  requirements:
105
- - - !binary |-
106
- fj4=
38
+ - - "~>"
107
39
  - !ruby/object:Gem::Version
108
- version: !binary |-
109
- MS4y
40
+ version: '3.0'
110
41
  - !ruby/object:Gem::Dependency
111
- name: !binary |-
112
- dW5pY29ybg==
42
+ name: posix_mq
113
43
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
44
  requirements:
116
- - - !binary |-
117
- Pj0=
45
+ - - "~>"
118
46
  - !ruby/object:Gem::Version
119
- version: !binary |-
120
- MC45OA==
47
+ version: '2.0'
121
48
  type: :development
122
49
  prerelease: false
123
50
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
51
  requirements:
126
- - - !binary |-
127
- Pj0=
52
+ - - "~>"
128
53
  - !ruby/object:Gem::Version
129
- version: !binary |-
130
- MC45OA==
54
+ version: '2.0'
131
55
  - !ruby/object:Gem::Dependency
132
- name: !binary |-
133
- d3Jvbmdkb2M=
56
+ name: rack
134
57
  requirement: !ruby/object:Gem::Requirement
135
- none: false
136
58
  requirements:
137
- - - !binary |-
138
- fj4=
59
+ - - ">="
139
60
  - !ruby/object:Gem::Version
140
- version: !binary |-
141
- MS42LjI=
142
- - - !binary |-
143
- Pj0=
61
+ version: '1.2'
62
+ - - "<"
144
63
  - !ruby/object:Gem::Version
145
- version: !binary |-
146
- MS42LjI=
64
+ version: '3.0'
147
65
  type: :development
148
66
  prerelease: false
149
67
  version_requirements: !ruby/object:Gem::Requirement
150
- none: false
151
68
  requirements:
152
- - - !binary |-
153
- fj4=
154
- - !ruby/object:Gem::Version
155
- version: !binary |-
156
- MS42LjI=
157
- - - !binary |-
158
- Pj0=
159
- - !ruby/object:Gem::Version
160
- version: !binary |-
161
- MS42LjI=
162
- description: ! 'Raindrops is a real-time stats toolkit to show statistics for Rack
163
- HTTP
164
-
165
- servers. It is designed for preforking servers such as Rainbows! and
166
-
167
- Unicorn, but should support any Rack HTTP server under Ruby 2.0, 1.9,
168
-
169
- 1.8 and Rubinius on platforms supporting POSIX shared memory. It may
170
-
171
- also be used as a generic scoreboard for sharing atomic counters across
172
-
173
- multiple processes.'
174
- email: !binary |-
175
- cmFpbmRyb3BzQGxpYnJlbGlzdC5vcmc=
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '1.2'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ description: |-
76
+ raindrops is a real-time stats toolkit to show statistics for Rack HTTP
77
+ servers. It is designed for preforking servers such as unicorn, but
78
+ should support any Rack HTTP server on platforms supporting POSIX shared
79
+ memory. It may also be used as a generic scoreboard for sharing atomic
80
+ counters across multiple processes.
81
+ email: raindrops-public@yhbt.net
176
82
  executables: []
177
83
  extensions:
178
- - !binary |-
179
- ZXh0L3JhaW5kcm9wcy9leHRjb25mLnJi
84
+ - ext/raindrops/extconf.rb
180
85
  extra_rdoc_files:
181
86
  - README
182
87
  - LICENSE
183
88
  - NEWS
184
- - ChangeLog
185
- - lib/raindrops.rb
186
- - lib/raindrops/aggregate.rb
187
- - lib/raindrops/aggregate/last_data_recv.rb
188
- - lib/raindrops/aggregate/pmq.rb
189
- - lib/raindrops/last_data_recv.rb
190
- - lib/raindrops/linux.rb
191
- - lib/raindrops/middleware.rb
192
- - lib/raindrops/middleware/proxy.rb
193
- - lib/raindrops/struct.rb
194
- - lib/raindrops/watcher.rb
195
89
  - ext/raindrops/raindrops.c
196
90
  - ext/raindrops/linux_inet_diag.c
197
- - ext/raindrops/linux_tcp_info.c
91
+ - ext/raindrops/tcp_info.c
198
92
  files:
199
- - .document
200
- - .gitignore
201
- - .manifest
202
- - .wrongdoc.yml
93
+ - ".document"
94
+ - ".gitattributes"
95
+ - ".gitignore"
96
+ - ".manifest"
97
+ - ".olddoc.yml"
203
98
  - COPYING
204
- - ChangeLog
205
99
  - GIT-VERSION-FILE
206
100
  - GIT-VERSION-GEN
207
101
  - GNUmakefile
@@ -209,19 +103,21 @@ files:
209
103
  - LICENSE
210
104
  - NEWS
211
105
  - README
212
- - Rakefile
213
106
  - TODO
107
+ - archive/.gitignore
108
+ - archive/slrnpull.conf
214
109
  - examples/linux-listener-stats.rb
215
110
  - examples/middleware.ru
216
111
  - examples/watcher.ru
217
112
  - examples/watcher_demo.ru
113
+ - examples/yahns.conf.rb
218
114
  - examples/zbatery.conf.rb
219
115
  - ext/raindrops/extconf.rb
220
116
  - ext/raindrops/linux_inet_diag.c
221
- - ext/raindrops/linux_tcp_info.c
222
117
  - ext/raindrops/my_fileno.h
223
118
  - ext/raindrops/raindrops.c
224
119
  - ext/raindrops/raindrops_atomic.h
120
+ - ext/raindrops/tcp_info.c
225
121
  - lib/raindrops.rb
226
122
  - lib/raindrops/aggregate.rb
227
123
  - lib/raindrops/aggregate/last_data_recv.rb
@@ -245,44 +141,36 @@ files:
245
141
  - test/test_linux_all_tcp_listen_stats_leak.rb
246
142
  - test/test_linux_ipv6.rb
247
143
  - test/test_linux_middleware.rb
248
- - test/test_linux_tcp_info.rb
249
144
  - test/test_middleware.rb
250
145
  - test/test_middleware_unicorn.rb
251
146
  - test/test_middleware_unicorn_ipv6.rb
252
147
  - test/test_raindrops.rb
253
148
  - test/test_raindrops_gc.rb
254
149
  - test/test_struct.rb
150
+ - test/test_tcp_info.rb
255
151
  - test/test_watcher.rb
256
- homepage: http://raindrops.bogomips.org/
152
+ homepage: https://yhbt.net/raindrops/
257
153
  licenses:
258
- - !binary |-
259
- TEdQTHYyLjEr
154
+ - LGPL-2.1+
155
+ metadata: {}
260
156
  post_install_message:
261
- rdoc_options:
262
- - -t
263
- - raindrops - real-time stats for preforking Rack servers
264
- - -W
265
- - http://bogomips.org/raindrops.git/tree/%s
157
+ rdoc_options: []
266
158
  require_paths:
267
159
  - lib
268
160
  required_ruby_version: !ruby/object:Gem::Requirement
269
- none: false
270
161
  requirements:
271
- - - ! '>='
162
+ - - ">="
272
163
  - !ruby/object:Gem::Version
273
- version: '0'
164
+ version: 1.9.3
274
165
  required_rubygems_version: !ruby/object:Gem::Requirement
275
- none: false
276
166
  requirements:
277
- - - ! '>='
167
+ - - ">="
278
168
  - !ruby/object:Gem::Version
279
169
  version: '0'
280
170
  requirements: []
281
- rubyforge_project: !binary |-
282
- cmFpbmJvd3M=
283
- rubygems_version: 1.8.23
171
+ rubygems_version: 3.0.2
284
172
  signing_key:
285
- specification_version: 3
173
+ specification_version: 4
286
174
  summary: real-time stats for preforking Rack servers
287
175
  test_files:
288
176
  - test/test_aggregate_pmq.rb
@@ -293,11 +181,11 @@ test_files:
293
181
  - test/test_linux_all_tcp_listen_stats_leak.rb
294
182
  - test/test_linux_ipv6.rb
295
183
  - test/test_linux_middleware.rb
296
- - test/test_linux_tcp_info.rb
297
184
  - test/test_middleware.rb
298
185
  - test/test_middleware_unicorn.rb
299
186
  - test/test_middleware_unicorn_ipv6.rb
300
187
  - test/test_raindrops.rb
301
188
  - test/test_raindrops_gc.rb
302
189
  - test/test_struct.rb
190
+ - test/test_tcp_info.rb
303
191
  - test/test_watcher.rb