1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/myapp/app/controllers/work_controller.rb

39 lines
826 B
Ruby
Raw Normal View History

class WorkController < ApplicationController
def index
@count = rand(100)
puts "Adding #{@count} jobs"
2012-02-12 15:22:01 -05:00
@count.times do |x|
2012-02-18 23:01:29 -05:00
HardWorker.perform_async('bubba', 0.01, x)
end
end
def email
UserMailer.delay_for(30.seconds).greetings(Time.now)
render :text => 'enqueued'
end
2012-02-18 23:01:29 -05:00
def long
50.times do |x|
2012-02-18 23:01:29 -05:00
HardWorker.perform_async('bob', 10, x)
end
render :text => 'enqueued'
end
2012-03-18 02:04:31 -04:00
def crash
HardWorker.perform_async('crash', 1, Time.now.to_f)
render :text => 'enqueued'
end
def delayed_post
p = Post.first
unless p
p = Post.create!(:title => "Title!", :body => 'Body!')
p2 = Post.create!(:title => "Other!", :body => 'Second Body!')
else
p2 = Post.second
end
p.delay.long_method(p2)
render :text => 'enqueued'
end
end