From e17c2e5da5010beaefb46c8fffe35e87cb28f407 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 14 Jun 2017 18:01:35 +0200 Subject: Batched remove status service (#3735) * Make Pubsubhubbub::DistributionWorker handle both single stream entry arguments, as well as arrays of stream entries * Add BatchedRemoveStatusService, make SuspendAccountService use it * Improve method names * Add test * Add more tests * Use PuSH payloads of 100 to have a clear mapping of 1000 input statuses -> 10 PuSH payloads It was nice while it lasted --- spec/workers/pubsubhubbub/distribution_worker_spec.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'spec/workers') diff --git a/spec/workers/pubsubhubbub/distribution_worker_spec.rb b/spec/workers/pubsubhubbub/distribution_worker_spec.rb index 512adb04c..89191c084 100644 --- a/spec/workers/pubsubhubbub/distribution_worker_spec.rb +++ b/spec/workers/pubsubhubbub/distribution_worker_spec.rb @@ -16,10 +16,9 @@ describe Pubsubhubbub::DistributionWorker do let(:status) { Fabricate(:status, account: alice, text: 'Hello', visibility: :public) } it 'delivers payload to all subscriptions' do - allow(Pubsubhubbub::DeliveryWorker).to receive(:perform_async) + allow(Pubsubhubbub::DeliveryWorker).to receive(:push_bulk) subject.perform(status.stream_entry.id) - expect(Pubsubhubbub::DeliveryWorker).to have_received(:perform_async).with(subscription_with_follower.id, /.*/) - expect(Pubsubhubbub::DeliveryWorker).to have_received(:perform_async).with(anonymous_subscription.id, /.*/) + expect(Pubsubhubbub::DeliveryWorker).to have_received(:push_bulk).with([anonymous_subscription, subscription_with_follower]) end end @@ -27,10 +26,10 @@ describe Pubsubhubbub::DistributionWorker do let(:status) { Fabricate(:status, account: alice, text: 'Hello', visibility: :private) } it 'delivers payload only to subscriptions with followers' do - allow(Pubsubhubbub::DeliveryWorker).to receive(:perform_async) + allow(Pubsubhubbub::DeliveryWorker).to receive(:push_bulk) subject.perform(status.stream_entry.id) - expect(Pubsubhubbub::DeliveryWorker).to have_received(:perform_async).with(subscription_with_follower.id, /.*/) - expect(Pubsubhubbub::DeliveryWorker).to_not have_received(:perform_async).with(anonymous_subscription.id, /.*/) + expect(Pubsubhubbub::DeliveryWorker).to have_received(:push_bulk).with([subscription_with_follower]) + expect(Pubsubhubbub::DeliveryWorker).to_not have_received(:push_bulk).with([anonymous_subscription]) end end @@ -38,9 +37,9 @@ describe Pubsubhubbub::DistributionWorker do let(:status) { Fabricate(:status, account: alice, text: 'Hello', visibility: :direct) } it 'does not deliver payload' do - allow(Pubsubhubbub::DeliveryWorker).to receive(:perform_async) + allow(Pubsubhubbub::DeliveryWorker).to receive(:push_bulk) subject.perform(status.stream_entry.id) - expect(Pubsubhubbub::DeliveryWorker).to_not have_received(:perform_async) + expect(Pubsubhubbub::DeliveryWorker).to_not have_received(:push_bulk) end end end -- cgit