2012-02-07 20:35:14 -05:00
|
|
|
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)
|
2012-02-07 20:35:14 -05:00
|
|
|
end
|
|
|
|
end
|
2012-02-18 00:24:14 -05:00
|
|
|
|
|
|
|
def email
|
2012-05-25 23:21:42 -04:00
|
|
|
UserMailer.delay_for(30.seconds).greetings(Time.now)
|
2012-11-26 11:22:48 -05:00
|
|
|
render :text => 'enqueued'
|
2012-02-18 00:24:14 -05:00
|
|
|
end
|
|
|
|
|
2013-03-24 20:42:43 -04:00
|
|
|
def bulk
|
|
|
|
Sidekiq::Client.push_bulk('class' => HardWorker,
|
|
|
|
'args' => [['bob', 1, 1], ['mike', 1, 2]])
|
|
|
|
render :text => 'enbulked'
|
|
|
|
end
|
|
|
|
|
2012-02-18 23:01:29 -05:00
|
|
|
def long
|
2012-03-06 23:17:42 -05:00
|
|
|
50.times do |x|
|
2013-06-11 01:20:15 -04:00
|
|
|
HardWorker.perform_async('bob', 15, x)
|
2012-02-18 23:01:29 -05:00
|
|
|
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
|
|
|
|
|
2012-02-18 00:24:14 -05:00
|
|
|
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)
|
2012-11-26 11:22:48 -05:00
|
|
|
render :text => 'enqueued'
|
2012-02-18 00:24:14 -05:00
|
|
|
end
|
2012-02-07 20:35:14 -05:00
|
|
|
end
|