feat: implement mutex for SlackSendJob (#7783)

This commit is contained in:
Shivam Mishra
2023-08-25 11:58:29 +07:00
committed by GitHub
parent 64ae9f625a
commit 5598b4b27e
6 changed files with 121 additions and 54 deletions

View File

@@ -1,7 +1,10 @@
class SendOnSlackJob < ApplicationJob
class SendOnSlackJob < MutexApplicationJob
queue_as :medium
retry_on LockAcquisitionError, wait: 1.second, attempts: 6
def perform(message, hook)
Integrations::Slack::SendOnSlackService.new(message: message, hook: hook).perform
with_lock(::Redis::Alfred::SLACK_MESSAGE_MUTEX, sender_id: message.sender_id, reference_id: hook.reference_id) do
Integrations::Slack::SendOnSlackService.new(message: message, hook: hook).perform
end
end
end