mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 22:06:47 +00:00
Adds workers
This commit is contained in:
parent
4c840bdff0
commit
9ca53ced37
14
lib/outboxable/polling_publisher_worker.rb
Normal file
14
lib/outboxable/polling_publisher_worker.rb
Normal 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
9
lib/outboxable/worker.rb
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user