Skip to content

Commit 6307f3f

Browse files
committed
async http stack! going meta, query yourself.. to hit async mysql!
1 parent 72ea384 commit 6307f3f

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.bundle
2+
db/*.sqlite3
3+
log/*.log
4+
tmp/**/*

Gemfile

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ source 'http://rubygems.org'
33
gem 'rails', '3.0.0.beta4'
44

55
# async activerecord requires
6-
gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git', :require => 'em-synchrony'
76
gem 'mysqlplus', :git => 'git://github.com/oldmoe/mysqlplus.git', :require => 'mysqlplus'
87
gem 'em-mysqlplus', :git => 'git://github.com/igrigorik/em-mysqlplus.git', :require => 'em-activerecord'
98

109
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
1110

11+
# async http requires
12+
gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git', :require => 'em-synchrony/em-http'
13+
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
14+
gem 'addressable', :require => 'addressable/uri'
15+
16+
17+
# require 'em-synchrony/em-http'
18+
1219

1320
# Bundle edge Rails instead:
1421
# gem 'rails', :git => 'git://github.com/rails/rails.git'

app/controllers/widgets_controller.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class WidgetsController < ApplicationController
2+
def index
3+
Widget.find_by_sql("select sleep(1)")
4+
render :text => "Oh hai"
5+
end
6+
7+
def http
8+
# going meta, query yourself, on the same thin server!
9+
http = EM::HttpRequest.new("http://localhost:3000/widgets").get
10+
render :text => http.response
11+
end
12+
end

app/models/widget.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Widget < ActiveRecord::Base
2+
end

0 commit comments

Comments
 (0)