-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PollingReceiverWorker class to handle inbox processing
- Loading branch information
1 parent
90e8fca
commit a7d02b8
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Inboxable | ||
class PollingReceiverWorker | ||
include Sidekiq::Job | ||
|
||
def perform | ||
perform_activerecord | ||
end | ||
|
||
def perform_activerecord | ||
Inbox.pending.where(last_attempted_at: [..Time.zone.now, nil]).find_in_batches(batch_size: ENV.fetch('INBOXABLE__BATCH_SIZE', 100).to_i).each do |batch| | ||
batch.each do |inbox| | ||
inbox.processor_class_name.constantize.perform_async(inbox.id) | ||
inbox.update(last_attempted_at: 1.minute.from_now, status: :processing, allow_publish: false) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Inboxable | ||
class PollingReceiverWorker | ||
def initialize: -> void | ||
def perform: -> void | ||
def perform_activerecord: -> void | ||
end | ||
end |