Adds workers

This commit is contained in:
Brusk Awat 2023-03-01 00:43:21 +03:00
parent 4c840bdff0
commit 9ca53ced37
Signed by: broosk1993
GPG Key ID: 5D20F7E02649F74E
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,14 @@
module Outboxable
class PollingPublisherWorker
include Sidekiq::Job
sidekiq_options queue: 'critical'
def perform
Outbox.pending.find_in_batches(batch_size: 100).each do |batch|
batch.each do |outbox|
Outboxable::Worker.perform_async(outbox.id)
end
end
end
end
end

9
lib/outboxable/worker.rb Normal file
View File

@ -0,0 +1,9 @@
module Outboxable
class Worker
include Sidekiq::Job
def perform(outbox_id)
Outboxable::PublishingManager.publish(resource: Outbox.find(outbox_id))
end
end
end