Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (44 sloc) 1.35 kb
1d869e35 »
2008-09-03 simple test
1 require 'lib/em/mysql'
2
14c1affc »
2008-09-07 use detach to remove socket from EM
3 # EM.kqueue
4 # EM.epoll
1d869e35 »
2008-09-03 simple test
5 EM.run{
14c1affc »
2008-09-07 use detach to remove socket from EM
6 EM.start_server '127.0.0.1', 12345 do |c|
7 def c.receive_data data
8 p 'sending http response'
9 send_data "hello"
10 close_connection_after_writing
11 end
12 end
13
1d869e35 »
2008-09-03 simple test
14 SQL = EventedMysql
15 def SQL(query, &blk) SQL.select(query, &blk) end
16
78d88433 »
2008-09-13 add more tests
17 if true
18
19 SQL.settings.update :logging => true,
20 :database => 'test',
21 :connections => 1
22
23 SQL.execute('select 1+2')
24
25 EM.add_timer(1){
26 3.times do SQL.select('select sleep(0.5)+1'){|r| p(r) } end
27 }
28
29 elsif false
30
31 SQL.settings.update :logging => true,
32 :database => 'test',
33 :connections => 10
1d869e35 »
2008-09-03 simple test
34
e3132c70 »
2008-09-04 two test modes: idle connections, and connection pool with periodic q…
35 EM.add_timer(2.5){ SQL.all('use test') }
1d869e35 »
2008-09-03 simple test
36
e3132c70 »
2008-09-04 two test modes: idle connections, and connection pool with periodic q…
37 else
38
78d88433 »
2008-09-13 add more tests
39 SQL.settings.update :logging => true,
40 :database => 'test',
41 :connections => 10,
42 :timeout => 1
43
e3132c70 »
2008-09-04 two test modes: idle connections, and connection pool with periodic q…
44 n = 0
78d88433 »
2008-09-13 add more tests
45
e3132c70 »
2008-09-04 two test modes: idle connections, and connection pool with periodic q…
46 SQL.execute('drop table if exists testingabc'){
47 SQL.execute('create table testingabc (a int, b int, c int)'){
48 EM.add_periodic_timer(0.2) do
49 cur_num = n+=1
50 SQL.execute("insert into testingabc values (1,2,#{cur_num})"){
51 SQL("select * from testingabc where c = #{cur_num} limit 1"){ |res| puts;puts }
52 }
53 end
54 }
1d869e35 »
2008-09-03 simple test
55 }
e3132c70 »
2008-09-04 two test modes: idle connections, and connection pool with periodic q…
56
57 end
58
1d869e35 »
2008-09-03 simple test
59 }
Something went wrong with that request. Please try again.