Permalink
Browse files

Sleepy app to test backgroundable and message load-balancing.

  • Loading branch information...
1 parent 2cc2666 commit ed9bb43ade356a79ce9b5a5076411099ffc3f0e3 @jcrossley3 jcrossley3 committed Jul 15, 2011
Showing with 33 additions and 0 deletions.
  1. +3 −0 sleepy/Gemfile
  2. +1 −0 sleepy/Rakefile
  3. +3 −0 sleepy/config.ru
  4. +14 −0 sleepy/sleeper.rb
  5. +12 −0 sleepy/sleepy.rb
View
@@ -0,0 +1,3 @@
+source "http://rubygems.org"
+gem "sinatra"
+gem "torquebox"
View
@@ -0,0 +1 @@
+require "torquebox-rake-support"
View
@@ -0,0 +1,3 @@
+require 'bundler/setup'
+require 'sleepy'
+run Sleepy
View
@@ -0,0 +1,14 @@
+require 'torquebox-messaging'
+
+class Sleeper
+
+ include TorqueBox::Messaging::Backgroundable
+ always_background :doze
+
+ def doze(duration)
+ puts "sleep #{duration}"
+ sleep( duration )
+ puts "awake #{duration}"
+ end
+
+end
View
@@ -0,0 +1,12 @@
+require 'sinatra'
+require 'sleeper'
+
+class Sleepy < Sinatra::Base
+
+ get '/snooze/:duration' do
+ duration = (params[:duration] || 1).to_i
+ puts "request #{duration}"
+ Sleeper.new.doze(duration)
+ end
+
+end

0 comments on commit ed9bb43

Please sign in to comment.