Revert "remove perform delegate: use a gem that unobtrusivly does the same"
the connection adapter messes with single process mode...
This reverts commit dd752d7dd9.
This commit is contained in:
parent
dd752d7dd9
commit
696779d589
27 changed files with 44 additions and 34 deletions
2
Gemfile
2
Gemfile
|
|
@ -58,7 +58,6 @@ gem "excon", "0.2.4"
|
|||
gem 'mini_magick', '3.2'
|
||||
gem 'aws', '2.3.32' # upgrade to 2.4 breaks 1.8 >.<
|
||||
|
||||
|
||||
gem 'fastercsv', '1.5.4', :require => false
|
||||
gem 'jammit', '0.5.4'
|
||||
gem 'rest-client', '1.6.1'
|
||||
|
|
@ -71,7 +70,6 @@ gem 'cloudfiles', '1.4.10', :require => false
|
|||
|
||||
#Queue
|
||||
gem 'resque', '1.10.0'
|
||||
gem 'resque-ensure-connected'
|
||||
gem 'SystemTimer', '1.2.1', :platforms => :ruby_18
|
||||
|
||||
group :development do
|
||||
|
|
|
|||
|
|
@ -351,9 +351,6 @@ GEM
|
|||
redis-namespace (~> 0.8.0)
|
||||
sinatra (>= 0.9.2)
|
||||
vegas (~> 0.1.2)
|
||||
resque-ensure-connected (0.1.0)
|
||||
activerecord (>= 2.3.5)
|
||||
resque (~> 1.10.0)
|
||||
rest-client (1.6.1)
|
||||
mime-types (>= 1.16)
|
||||
rspec (2.6.0)
|
||||
|
|
@ -490,7 +487,6 @@ DEPENDENCIES
|
|||
rails (= 3.0.3)
|
||||
rcov
|
||||
resque (= 1.10.0)
|
||||
resque-ensure-connected
|
||||
rest-client (= 1.6.1)
|
||||
roxml!
|
||||
rspec (>= 2.0.0)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,16 @@
|
|||
module Job
|
||||
class Base
|
||||
extend ResqueJobLogging
|
||||
|
||||
# Perform this job. This wrapper method
|
||||
def self.perform(*args)
|
||||
ActiveRecord::Base.verify_active_connections!
|
||||
self.perform_delegate(*args)
|
||||
end
|
||||
|
||||
# Override this in your Job class.
|
||||
# @abstract
|
||||
def self.perform_delegate(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class DeleteAccount < Base
|
||||
@queue = :delete_account
|
||||
def self.perform(user_id)
|
||||
def self.perform_delegate(user_id)
|
||||
user = User.find(user_id)
|
||||
user.remove_all_traces
|
||||
user.destroy
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module Job
|
|||
MAX_RETRIES = 3
|
||||
OPTS = {:max_redirects => 3, :timeout => 5000, :method => :post}
|
||||
|
||||
def self.perform(user_id, enc_object_xml, person_ids, retry_count=0)
|
||||
def self.perform_delegate(user_id, enc_object_xml, person_ids, retry_count=0)
|
||||
user = User.find(user_id)
|
||||
people = Person.where(:id => person_ids)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Job
|
|||
@queue = :http
|
||||
NUM_TRIES = 3
|
||||
|
||||
def self.perform(url, body, tries_remaining = NUM_TRIES)
|
||||
def self.perform_delegate(url, body, tries_remaining = NUM_TRIES)
|
||||
begin
|
||||
body = CGI::escape(body)
|
||||
RestClient.post(url, :xml => body){ |response, request, result, &block|
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class InviteUserByEmail < Base
|
||||
@queue = :mail
|
||||
def self.perform(sender_id, email, aspect_id, invite_message)
|
||||
def self.perform_delegate(sender_id, email, aspect_id, invite_message)
|
||||
user = User.find(sender_id)
|
||||
user.invite_user(aspect_id, 'email', email, invite_message)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Job
|
||||
class MailAlsoCommented < Base
|
||||
@queue = :mail
|
||||
def self.perform(recipient_id, sender_id, comment_id)
|
||||
def self.perform_delegate(recipient_id, sender_id, comment_id)
|
||||
Notifier.also_commented(recipient_id, sender_id, comment_id).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Job
|
||||
class MailCommentOnPost < Base
|
||||
@queue = :mail
|
||||
def self.perform(recipient_id, sender_id, comment_id)
|
||||
def self.perform_delegate(recipient_id, sender_id, comment_id)
|
||||
Notifier.comment_on_post(recipient_id, sender_id, comment_id).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Job
|
||||
class MailLiked < Base
|
||||
@queue = :mail
|
||||
def self.perform(recipient_id, sender_id, like_id)
|
||||
def self.perform_delegate(recipient_id, sender_id, like_id)
|
||||
Notifier.liked(recipient_id, sender_id, like_id).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class MailMentioned < Base
|
||||
@queue = :mail
|
||||
def self.perform(recipient_id, actor_id, target_id)
|
||||
def self.perform_delegate(recipient_id, actor_id, target_id)
|
||||
|
||||
Notifier.mentioned( recipient_id, actor_id, target_id).deliver
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class MailPrivateMessage < Base
|
||||
@queue = :mail
|
||||
def self.perform(recipient_id, actor_id, target_id)
|
||||
def self.perform_delegate(recipient_id, actor_id, target_id)
|
||||
Notifier.private_message( recipient_id, actor_id, target_id).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class MailStartedSharing < Base
|
||||
@queue = :mail
|
||||
def self.perform(recipient_id, sender_id, target_id)
|
||||
def self.perform_delegate(recipient_id, sender_id, target_id)
|
||||
Notifier.started_sharing(recipient_id, sender_id).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Job
|
|||
|
||||
require File.join(Rails.root, 'app/models/notification')
|
||||
|
||||
def self.perform(user_ids, object_klass, object_id, person_id)
|
||||
def self.perform_delegate(user_ids, object_klass, object_id, person_id)
|
||||
users = User.where(:id => user_ids)
|
||||
object = object_klass.constantize.find_by_id(object_id)
|
||||
person = Person.find_by_id(person_id)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module Job
|
|||
class PostToService < Base
|
||||
@queue = :http_service
|
||||
|
||||
def self.perform(service_id, post_id, url)
|
||||
def self.perform_delegate(service_id, post_id, url)
|
||||
service = Service.find_by_id(service_id)
|
||||
post = Post.find_by_id(post_id)
|
||||
service.post(post, url)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class ProcessPhoto < Base
|
||||
@queue = :photos
|
||||
def self.perform(photo_id)
|
||||
def self.perform_delegate(photo_id)
|
||||
Photo.find(photo_id).process
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module Job
|
|||
class PublishToHub < Base
|
||||
@queue = :http_service
|
||||
|
||||
def self.perform(sender_public_url)
|
||||
def self.perform_delegate(sender_public_url)
|
||||
require File.join(Rails.root, 'lib/pubsubhubbub')
|
||||
atom_url = sender_public_url + '.atom'
|
||||
Pubsubhubbub.new(AppConfig[:pubsub_server]).publish(atom_url)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Job
|
|||
require File.join(Rails.root, 'lib/postzord/receiver')
|
||||
|
||||
@queue = :receive
|
||||
def self.perform(post_id, recipient_user_ids)
|
||||
def self.perform_delegate(post_id, recipient_user_ids)
|
||||
post = Post.find(post_id)
|
||||
create_visibilities(post, recipient_user_ids)
|
||||
socket_to_users(post, recipient_user_ids) if post.respond_to?(:socket_to_user)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Job
|
|||
class ReceiveSalmon < Base
|
||||
@queue = :receive_salmon
|
||||
|
||||
def self.perform(user_id, xml)
|
||||
def self.perform_delegate(user_id, xml)
|
||||
user = User.find(user_id)
|
||||
zord = Postzord::Receiver.new(user, :salmon_xml => xml)
|
||||
zord.perform
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class ResendInvitation < Base
|
||||
@queue = :mail
|
||||
def self.perform(invitation_id)
|
||||
def self.perform_delegate(invitation_id)
|
||||
inv = Invitation.where(:id => invitation_id).first
|
||||
inv.resend
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Job
|
|||
|
||||
@queue = :socket_webfinger
|
||||
|
||||
def self.perform(user_id, account, opts={})
|
||||
def self.perform_delegate(user_id, account, opts={})
|
||||
finger = Webfinger.new(account)
|
||||
begin
|
||||
result = finger.fetch
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
module Job
|
||||
class UpdateServiceUsers < Base
|
||||
@queue = :http_service
|
||||
def self.perform(service_id)
|
||||
def self.perform_delegate(service_id)
|
||||
service = Service.find(service_id)
|
||||
service.save_friends
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ begin
|
|||
if Rails.env == 'production'
|
||||
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
|
||||
end
|
||||
Resque.inline = true
|
||||
|
||||
module Resque
|
||||
def enqueue(klass, *args)
|
||||
klass.send(:perform, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Job::MailMentioned do
|
||||
describe '#perfom' do
|
||||
describe '#perfom_delegate' do
|
||||
it 'should call .deliver on the notifier object' do
|
||||
user = alice
|
||||
sm = Factory(:status_message)
|
||||
|
|
@ -15,7 +15,7 @@ describe Job::MailMentioned do
|
|||
mail_mock.should_receive(:deliver)
|
||||
Notifier.should_receive(:mentioned).with(user.id, sm.author.id, m.id).and_return(mail_mock)
|
||||
|
||||
Job::MailMentioned.perform(user.id, sm.author.id, m.id)
|
||||
Job::MailMentioned.perform_delegate(user.id, sm.author.id, m.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe Job::MailPrivateMessage do
|
|||
mail_mock.should_receive(:deliver)
|
||||
Notifier.should_receive(:mentioned).with(user2.id, user1.person.id, message.id).and_return(mail_mock)
|
||||
|
||||
Job::MailMentioned.perform(user2.id, user1.person.id, message.id)
|
||||
Job::MailMentioned.perform_delegate(user2.id, user1.person.id, message.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@ describe Job::ReceiveLocalBatch do
|
|||
@post = alice.build_post(:status_message, :text => 'Hey Bob')
|
||||
@post.save!
|
||||
end
|
||||
describe '.perform' do
|
||||
describe '.perform_delegate' do
|
||||
it 'calls .create_visibilities' do
|
||||
Job::ReceiveLocalBatch.should_receive(:create_visibilities).with(@post, [bob.id])
|
||||
Job::ReceiveLocalBatch.perform(@post.id, [bob.id])
|
||||
Job::ReceiveLocalBatch.perform_delegate(@post.id, [bob.id])
|
||||
end
|
||||
it 'sockets to users' do
|
||||
Job::ReceiveLocalBatch.should_receive(:socket_to_users).with(@post, [bob.id])
|
||||
Job::ReceiveLocalBatch.perform(@post.id, [bob.id])
|
||||
Job::ReceiveLocalBatch.perform_delegate(@post.id, [bob.id])
|
||||
end
|
||||
it 'notifies mentioned users' do
|
||||
Job::ReceiveLocalBatch.should_receive(:notify_mentioned_users).with(@post)
|
||||
Job::ReceiveLocalBatch.perform(@post.id, [bob.id])
|
||||
Job::ReceiveLocalBatch.perform_delegate(@post.id, [bob.id])
|
||||
end
|
||||
end
|
||||
describe '.create_visibilities' do
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe Job::ResendInvitation do
|
|||
#Notification.should_receive(:notify).with(instance_of(User), instance_of(StatusMessage), instance_of(Person))
|
||||
Invitation.stub(:where).with(:id => invitation.id ).and_return([invitation])
|
||||
invitation.should_receive(:resend)
|
||||
Job::ResendInvitation.perform(invitation.id)
|
||||
Job::ResendInvitation.perform_delegate(invitation.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue