iodine 0.7.9 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of iodine might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +8 -2
- data/CHANGELOG.md +14 -0
- data/README.md +85 -29
- data/{examples → bin}/info.md +0 -0
- data/bin/{mustache.rb → mustache_bench.rb} +0 -0
- data/examples/shootout.ru +4 -4
- data/ext/iodine/extconf.rb +1 -1
- data/ext/iodine/fio.c +738 -549
- data/ext/iodine/fio.h +4 -5
- data/ext/iodine/fiobj_mustache.c +1 -1
- data/ext/iodine/fiobj_numbers.c +3 -3
- data/ext/iodine/http.c +15 -14
- data/ext/iodine/http1.c +6 -6
- data/ext/iodine/http1_parser.c +3 -3
- data/ext/iodine/http_internal.c +3 -3
- data/ext/iodine/http_internal.h +1 -1
- data/ext/iodine/iodine.c +7 -8
- data/ext/iodine/iodine_connection.c +48 -8
- data/ext/iodine/iodine_defer.c +7 -7
- data/ext/iodine/iodine_mustache.c +1 -1
- data/ext/iodine/redis_engine.c +4 -4
- data/ext/iodine/websockets.c +41 -22
- data/ext/iodine/websockets.h +13 -12
- data/iodine.gemspec +0 -2
- data/lib/iodine.rb +4 -0
- data/lib/iodine/version.rb +1 -1
- data/lib/rack/handler/iodine.rb +2 -4
- metadata +5 -39
- data/bin/config.ru +0 -97
- data/bin/echo +0 -46
- data/bin/http-big +0 -63
- data/bin/http-hello +0 -62
- data/bin/http-playground +0 -124
- data/bin/playground +0 -62
- data/bin/raw-rbhttp +0 -38
- data/bin/raw-rbhttp-em +0 -63
- data/bin/raw_broadcast +0 -64
- data/bin/test_with_faye +0 -44
- data/bin/updated api +0 -113
- data/bin/ws-broadcast +0 -106
- data/bin/ws-echo +0 -117
- data/examples/test_template.mustache +0 -16
data/bin/updated api
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
Dir.chdir(File.expand_path(File.join('..', '..'), __FILE__))
|
4
|
-
puts `rake clean`
|
5
|
-
puts `rake compile`
|
6
|
-
|
7
|
-
require 'benchmark'
|
8
|
-
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__)
|
9
|
-
require 'bundler/setup'
|
10
|
-
require 'iodine'
|
11
|
-
require 'rack'
|
12
|
-
|
13
|
-
class WSEcho
|
14
|
-
def self.call(env)
|
15
|
-
if env['upgrade.websocket?'.freeze] # && env['HTTP_UPGRADE'.freeze] =~ /websocket/i
|
16
|
-
env['upgrade.websocket'.freeze] = WSEcho
|
17
|
-
return [0, {}, []]
|
18
|
-
end
|
19
|
-
out = "ENV:\r\n#{env.to_a.map { |h| "#{h[0]}: #{h[1]}" } .join "\n"}\n"
|
20
|
-
request = Rack::Request.new(env)
|
21
|
-
out += "\nRequest Path: #{request.path_info}\nParams:\r\n#{request.params.to_a.map { |h| "#{h[0]}: #{h[1]}" } .join "\n"}\n" unless request.params.empty?
|
22
|
-
[200, { 'Content-Length' => out.length, 'Content-Type' => 'text/plain; charset=UTF-8;' }, [out]]
|
23
|
-
end
|
24
|
-
|
25
|
-
def on_open
|
26
|
-
puts 'We have a websocket connection'
|
27
|
-
Iodine::Websocket.defer(uuid) { |ws| puts "This websocket's uuid is #{ws.uuid}" }
|
28
|
-
end
|
29
|
-
|
30
|
-
def on_close
|
31
|
-
puts "Bye Bye... only #{count} left..."
|
32
|
-
end
|
33
|
-
|
34
|
-
def on_shutdown
|
35
|
-
puts "I'm shutting down #{self}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def on_drained
|
39
|
-
puts "on_drained called for #{self}"
|
40
|
-
end
|
41
|
-
|
42
|
-
def on_message(data)
|
43
|
-
puts "got message: #{data}"
|
44
|
-
write data
|
45
|
-
write (data * 16_384) if data =~ /^multi me$/
|
46
|
-
end
|
47
|
-
|
48
|
-
def echo(data)
|
49
|
-
write "echo: #{data}"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# create the server object and setup any settings we might need.
|
54
|
-
Iodine.threads ||= 4
|
55
|
-
Iodine.processes ||= 1
|
56
|
-
count = 2
|
57
|
-
|
58
|
-
Iodine::HTTP.listen app: WSEcho, log: true, port: 3000
|
59
|
-
Iodine.start
|
60
|
-
# server.on_http= Proc.new do |env|
|
61
|
-
# # [200, {"Content-Length".freeze => "12".freeze}, ["Hello World!".freeze]];
|
62
|
-
# if env["HTTP_UPGRADE".freeze] =~ /websocket/i.freeze
|
63
|
-
# env['iodine.websocket'.freeze] = WSEcho.new
|
64
|
-
# [0,{}, []]
|
65
|
-
# else
|
66
|
-
# req = Rack::Request.new env
|
67
|
-
# res = Rack::Response.new
|
68
|
-
# res.write "Hello World!".freeze
|
69
|
-
# res.to_a
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
|
73
|
-
# server.on_start do
|
74
|
-
# server.run_every(1000) {puts "#{server.connection_count} clients connected."}
|
75
|
-
# end
|
76
|
-
|
77
|
-
# puts "Press enter to start (#{Process.pid})"
|
78
|
-
# gets
|
79
|
-
|
80
|
-
# def nag
|
81
|
-
# puts `ab -n 200000 -c 2000 -k http://127.0.0.1:3000/`
|
82
|
-
# sleep 2
|
83
|
-
# end
|
84
|
-
#
|
85
|
-
# nag while true
|
86
|
-
#
|
87
|
-
# def nag
|
88
|
-
# puts `wrk -c2000 -d10 -t4 http://localhost:3000/`
|
89
|
-
# sleep 3
|
90
|
-
# end
|
91
|
-
#
|
92
|
-
# nag while true
|
93
|
-
|
94
|
-
# ab -n 100000 -c 200 -k http://127.0.0.1:3000/
|
95
|
-
# ab -n 100000 -c 4000 -k http://127.0.0.1:3000/
|
96
|
-
# ab -n 1000000 -c 20000 -k http://127.0.0.1:3000/
|
97
|
-
# ~/ruby/wrk/wrk -c400 -d10 -t12 http://localhost:3000/
|
98
|
-
# wrk -c200 -d4 -t12 http://localhost:3000/
|
99
|
-
# ab -n 2000 -c 20 -H "Connection: close" http://127.0.0.1:3000/
|
100
|
-
# RACK_ENV="production" rackup -p 3000 -s iodine
|
101
|
-
|
102
|
-
# thor --amount 5000 ws://localhost:3000/echo
|
103
|
-
# thor --amount 5000 ws://localhost:3000/broadcast
|
104
|
-
|
105
|
-
# ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);}; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");};
|
106
|
-
# for(i = 0; i< 256; i++) {
|
107
|
-
# ws = new WebSocket("ws://localhost:3000");
|
108
|
-
# ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data); e.target.close(); };
|
109
|
-
# ws.onclose = function(e) {console.log("closed")};
|
110
|
-
# ws.onopen = function(e) {e.target.send("hi");};
|
111
|
-
# };
|
112
|
-
# ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message " + e.data.length + " bytes long"); for(var i = 0; i < e.data.length ; i += 4) {if (e.data.slice(i, i+4) != "text") {console.log( "incoming message corrupted? ", e.data.slice(i, i+4) ); return;};}; }; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");};
|
113
|
-
# str = "text"; function size_test() { if(ws.readyState != 1) return; if(str.length > 4194304) {console.log("str reached 4MiB!"); str = "test"; return;}; ws.send(str); str = str + str; window.setTimeout(size_test, 150); }; size_test();
|
data/bin/ws-broadcast
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
Dir.chdir(File.expand_path(File.join('..', '..'), __FILE__))
|
4
|
-
puts `rake clean`
|
5
|
-
puts `rake compile`
|
6
|
-
|
7
|
-
require 'benchmark'
|
8
|
-
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__)
|
9
|
-
require 'bundler/setup'
|
10
|
-
require 'iodine'
|
11
|
-
require 'rack'
|
12
|
-
|
13
|
-
class WSEcho
|
14
|
-
def self.call(env)
|
15
|
-
if env['HTTP_UPGRADE'.freeze] =~ /websocket/i
|
16
|
-
env['iodine.websocket'.freeze] = WSEcho
|
17
|
-
return [0, {}, []]
|
18
|
-
end
|
19
|
-
out = "ENV:\r\n#{env.to_a.map { |h| "#{h[0]}: #{h[1]}" } .join "\n"}"
|
20
|
-
request = Rack::Request.new(env)
|
21
|
-
pr_raise if request.path_info =~ /raise[.]*/
|
22
|
-
out += "\nRequest Path: #{request.path_info}\nParams:\r\n#{request.params.to_a.map { |h| "#{h[0]}: #{h[1]}" } .join "\n"}" unless request.params.empty?
|
23
|
-
[200, { 'Content-Length' => out.length }, [out]]
|
24
|
-
end
|
25
|
-
|
26
|
-
def on_open
|
27
|
-
puts 'We have a websocket connection'
|
28
|
-
subscribe channel: :all
|
29
|
-
end
|
30
|
-
|
31
|
-
def on_close
|
32
|
-
puts "Bye Bye... only #{count} left..."
|
33
|
-
end
|
34
|
-
|
35
|
-
def on_shutdown
|
36
|
-
puts "I'm shutting down #{self}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def on_message(data)
|
40
|
-
puts "got message: #{data}"
|
41
|
-
publish channe: :all, message: data
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.pr_raise
|
45
|
-
raise 'hell'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# create the server object and setup any settings we might need.
|
50
|
-
Iodine.threads ||= 4
|
51
|
-
Iodine.processes ||= 1
|
52
|
-
Iodine::Rack.public = nil
|
53
|
-
Iodine::Rack.log = 1
|
54
|
-
Iodine::Rack.app = WSEcho
|
55
|
-
# puts "Press enter to start (#{Process.pid})"
|
56
|
-
# gets
|
57
|
-
Iodine.start
|
58
|
-
|
59
|
-
# server.on_start do
|
60
|
-
# # server.run {puts "I'm running!"}
|
61
|
-
# # server.run_after(5000) {puts "5 seconds have passed."}
|
62
|
-
# server.run_every(1000) { puts "#{server.count} clients connected." }
|
63
|
-
# # server.run_every(10000) do
|
64
|
-
# # begin
|
65
|
-
# # puts "making a system call"
|
66
|
-
# # puts `ab -n 100000 -c 200 -k http://127.0.0.1:3000/`
|
67
|
-
# # rescue => e
|
68
|
-
# # l = Logger.new STDOUT
|
69
|
-
# # l.error e
|
70
|
-
# # end
|
71
|
-
# # end
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
# Iodine.run_every(1000) {puts "#{server.connection_count} clients connected."}
|
75
|
-
|
76
|
-
# def nag
|
77
|
-
# puts `ab -n 200000 -c 2000 -k http://127.0.0.1:3000/`
|
78
|
-
# sleep 2
|
79
|
-
# end
|
80
|
-
#
|
81
|
-
# nag while true
|
82
|
-
#
|
83
|
-
# def nag
|
84
|
-
# puts `wrk -c2000 -d10 -t4 http://localhost:3000/`
|
85
|
-
# sleep 3
|
86
|
-
# end
|
87
|
-
#
|
88
|
-
# nag while true
|
89
|
-
|
90
|
-
# ab -n 100000 -c 200 -k http://127.0.0.1:3000/
|
91
|
-
# ab -n 100000 -c 4000 -k http://127.0.0.1:3000/
|
92
|
-
# ab -n 1000000 -c 20000 -k http://127.0.0.1:3000/
|
93
|
-
# ~/ruby/wrk/wrk -c400 -d10 -t12 http://localhost:3000/
|
94
|
-
# wrk -c200 -d4 -t12 http://localhost:3000/
|
95
|
-
# RACK_ENV="production" rackup -p 3000 -s iodine
|
96
|
-
|
97
|
-
# thor --amount 5000 ws://localhost:3000/echo
|
98
|
-
# thor --amount 5000 ws://localhost:3000/broadcast
|
99
|
-
|
100
|
-
# ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);}; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");};
|
101
|
-
# for(i = 0; i< 256; i++) {
|
102
|
-
# ws = new WebSocket("ws://localhost:3000/");
|
103
|
-
# ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data); window.setTimeout(function(iws) {iws.send("leaving soon...");}, 3000, e.target); window.setTimeout(function(iws) {iws.close();}, 5000, e.target); };
|
104
|
-
# ws.onclose = function(e) {console.log("closed")};
|
105
|
-
# ws.onopen = function(e) {e.target.send("hi");};
|
106
|
-
# };
|
data/bin/ws-echo
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
$VERBOSE = true
|
5
|
-
|
6
|
-
Dir.chdir(File.expand_path(File.join('..', '..'), __FILE__))
|
7
|
-
puts `rake clean`
|
8
|
-
puts `rake compile`
|
9
|
-
|
10
|
-
require 'benchmark'
|
11
|
-
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__)
|
12
|
-
require 'bundler/setup'
|
13
|
-
require 'iodine'
|
14
|
-
require 'rack'
|
15
|
-
|
16
|
-
class WSEcho
|
17
|
-
def self.call(env)
|
18
|
-
if env['upgrade.websocket?'.freeze] # && env['HTTP_UPGRADE'.freeze] =~ /websocket/i
|
19
|
-
env['upgrade.websocket'.freeze] = WSEcho
|
20
|
-
return [0, {}, []]
|
21
|
-
end
|
22
|
-
out = "ENV:\r\n#{env.to_a.map { |h| "#{h[0]}: #{h[1]}" } .join "\n"}\n"
|
23
|
-
request = Rack::Request.new(env)
|
24
|
-
out += "\nRequest Path: #{request.path_info}\nParams:\r\n#{request.params.to_a.map { |h| "#{h[0]}: #{h[1]}" } .join "\n"}\n" unless request.params.empty?
|
25
|
-
[200, { 'Content-Length' => out.length, 'Content-Type' => 'text/plain; charset=UTF-8;' }, [out]]
|
26
|
-
end
|
27
|
-
|
28
|
-
def on_open
|
29
|
-
puts 'We have a websocket connection'
|
30
|
-
Iodine::Websocket.defer(uuid) { |ws| puts "This websocket's uuid is #{ws.uuid}" }
|
31
|
-
end
|
32
|
-
|
33
|
-
def on_close
|
34
|
-
puts "Bye Bye... only #{count} left..."
|
35
|
-
end
|
36
|
-
|
37
|
-
def on_shutdown
|
38
|
-
puts "I'm shutting down #{self}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def on_drained
|
42
|
-
puts "on_drained called for #{self}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def on_message(data)
|
46
|
-
puts "got message: #{data}"
|
47
|
-
write data
|
48
|
-
write (data * 16_384) if data =~ /^multi me$/
|
49
|
-
end
|
50
|
-
|
51
|
-
def echo(data)
|
52
|
-
write "echo: #{data}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# create the server object and setup any settings we might need.
|
57
|
-
Iodine.threads ||= 4
|
58
|
-
Iodine.processes ||= 1
|
59
|
-
Iodine::Rack.public = nil
|
60
|
-
Iodine::Rack.log = 1
|
61
|
-
count = 2
|
62
|
-
Iodine::Rack.app = WSEcho
|
63
|
-
Iodine.start
|
64
|
-
# server.on_http= Proc.new do |env|
|
65
|
-
# # [200, {"Content-Length".freeze => "12".freeze}, ["Hello World!".freeze]];
|
66
|
-
# if env["HTTP_UPGRADE".freeze] =~ /websocket/i.freeze
|
67
|
-
# env['iodine.websocket'.freeze] = WSEcho.new
|
68
|
-
# [0,{}, []]
|
69
|
-
# else
|
70
|
-
# req = Rack::Request.new env
|
71
|
-
# res = Rack::Response.new
|
72
|
-
# res.write "Hello World!".freeze
|
73
|
-
# res.to_a
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
|
77
|
-
# server.on_start do
|
78
|
-
# server.run_every(1000) {puts "#{server.connection_count} clients connected."}
|
79
|
-
# end
|
80
|
-
|
81
|
-
# puts "Press enter to start (#{Process.pid})"
|
82
|
-
# gets
|
83
|
-
|
84
|
-
# def nag
|
85
|
-
# puts `ab -n 200000 -c 2000 -k http://127.0.0.1:3000/`
|
86
|
-
# sleep 2
|
87
|
-
# end
|
88
|
-
#
|
89
|
-
# nag while true
|
90
|
-
#
|
91
|
-
# def nag
|
92
|
-
# puts `wrk -c2000 -d10 -t4 http://localhost:3000/`
|
93
|
-
# sleep 3
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
# nag while true
|
97
|
-
|
98
|
-
# ab -n 100000 -c 200 -k http://127.0.0.1:3000/
|
99
|
-
# ab -n 100000 -c 4000 -k http://127.0.0.1:3000/
|
100
|
-
# ab -n 1000000 -c 20000 -k http://127.0.0.1:3000/
|
101
|
-
# ~/ruby/wrk/wrk -c400 -d10 -t12 http://localhost:3000/
|
102
|
-
# wrk -c200 -d4 -t12 http://localhost:3000/
|
103
|
-
# ab -n 2000 -c 20 -H "Connection: close" http://127.0.0.1:3000/
|
104
|
-
# RACK_ENV="production" rackup -p 3000 -s iodine
|
105
|
-
|
106
|
-
# thor --amount 5000 ws://localhost:3000/echo
|
107
|
-
# thor --amount 5000 ws://localhost:3000/broadcast
|
108
|
-
|
109
|
-
# ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);}; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");};
|
110
|
-
# for(i = 0; i< 256; i++) {
|
111
|
-
# ws = new WebSocket("ws://localhost:3000");
|
112
|
-
# ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data); e.target.close(); };
|
113
|
-
# ws.onclose = function(e) {console.log("closed")};
|
114
|
-
# ws.onopen = function(e) {e.target.send("hi");};
|
115
|
-
# };
|
116
|
-
# ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message " + e.data.length + " bytes long"); for(var i = 0; i < e.data.length ; i += 4) {if (e.data.slice(i, i+4) != "text") {console.log( "incoming message corrupted? ", e.data.slice(i, i+4) ); return;};}; }; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");};
|
117
|
-
# str = "text"; function size_test() { if(ws.readyState != 1) return; if(str.length > 4194304) {console.log("str reached 4MiB!"); str = "test"; return;}; ws.send(str); str = str + str; window.setTimeout(size_test, 150); }; size_test();
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
{{#products}}
|
3
|
-
<div class='product_brick'>
|
4
|
-
<div class='container'>
|
5
|
-
<div class='element'>
|
6
|
-
<img src='images/{{image}}' class='product_miniature' />
|
7
|
-
</div>
|
8
|
-
<div class='element description'>
|
9
|
-
<a href={{url}} class='product_name block bold'>
|
10
|
-
{{external_index}}
|
11
|
-
</a>
|
12
|
-
</div>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
{{/products}}
|
16
|
-
|