FIX: Ensure web hooks are retried at most 5 times
This commit is contained in:
parent
6ba326a9f4
commit
cf0c6d5761
|
@ -93,6 +93,7 @@ module Jobs
|
|||
@retry_count += 1
|
||||
return if @retry_count > MAX_RETRY_COUNT
|
||||
delay = RETRY_BACKOFF**(@retry_count - 1)
|
||||
@arguments[:retry_count] = @retry_count
|
||||
::Jobs.enqueue_in(delay.minutes, :emit_web_hook_event, @arguments)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -90,6 +90,19 @@ describe Jobs::EmitWebHookEvent do
|
|||
end.to change { Jobs::EmitWebHookEvent.jobs.size }.by(1)
|
||||
end
|
||||
|
||||
it 'retries at most 5 times' do
|
||||
Jobs.run_immediately!
|
||||
|
||||
expect(Jobs::EmitWebHookEvent::MAX_RETRY_COUNT + 1).to eq(5)
|
||||
|
||||
expect do
|
||||
subject.execute(
|
||||
web_hook_id: post_hook.id,
|
||||
event_type: described_class::PING_EVENT
|
||||
)
|
||||
end.to change { WebHookEvent.count }.by(Jobs::EmitWebHookEvent::MAX_RETRY_COUNT + 1)
|
||||
end
|
||||
|
||||
it 'does not retry for more than maximum allowed times' do
|
||||
expect do
|
||||
subject.execute(
|
||||
|
|
Loading…
Reference in New Issue