diff --git a/Gemfile b/Gemfile index a2cc99d..c04ce71 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,9 @@ group :example do gem 'activerecord', '3.0.4' gem 'mysql2' + gem 'em-http-request' + gem 'em-synchrony' + gem 'rainbows' gem 'yajl-ruby', :require => 'yajl' gem 'http_router' diff --git a/Gemfile.lock b/Gemfile.lock index 455072d..fbe6c31 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,9 +19,17 @@ GEM arel (~> 2.0.2) tzinfo (~> 0.3.23) activesupport (3.0.4) + addressable (2.2.4) arel (2.0.8) builder (2.1.2) daemons (1.1.0) + em-http-request (0.3.0) + addressable (>= 2.0.0) + escape_utils + eventmachine (>= 0.12.9) + em-synchrony (0.2.0) + eventmachine (>= 0.12.9) + escape_utils (0.2.0) eventmachine (0.12.10) http_router (0.5.3) rack (>= 1.0.0) @@ -52,6 +60,8 @@ DEPENDENCIES activerecord (= 3.0.4) activesupport (= 3.0.4) cramp! + em-http-request + em-synchrony eventmachine (~> 0.12.10) http_router mysql2 diff --git a/examples/fibers/synchrony_http.ru b/examples/fibers/synchrony_http.ru new file mode 100644 index 0000000..2a5381d --- /dev/null +++ b/examples/fibers/synchrony_http.ru @@ -0,0 +1,21 @@ +require "rubygems" +require "bundler" +Bundler.setup(:default, :example) + +require 'cramp' +require 'em-http-request' +require 'em-synchrony/em-http' + +class SynchronyController < Cramp::Action + use_fiber_pool + + def start + page = EventMachine::HttpRequest.new("http://m.onkey.org").get + render page.response + finish + end +end + +# bundle exec thin -V -R examples/fibers/synchrony_http.ru start +# bundle exec rainbows -E deployment -c examples/rainbows.conf examples/fibers/synchrony_http.ru +run SynchronyController