demarches-normaliennes/app/jobs/web_hook_job.rb
mfo 08ec45443d
BREAKING(sidekiq.queues): rationalize queues. now have critical, default, low
Dear instances, make sure to update your sidekiq processes. Indead, we are adopting a new strategy for daemons that process our background
jobs.

Now their is only 3 queues on sidekiq (still, we keep archive/export on delayed job for now).

The big idea : allow any worker to deal with any queue (capacity mgmt) :
- critical: must be procesed now
- default: will be processed asap
- low: do it after everything else

FYI: we had 50% of our server capacity on reserved queues. Leading to
bottle neck processing (reserved queues/worker not processing other
queues). We HAD TO fix it. Sorry for the inconvenience

TBH, this is an idea of Colin Darie <colin@darie.eu>. I'm just pushing
it forward.

Co-Authored-By: Colin Darie <colin@darie.eu>
2024-09-24 21:29:11 +02:00

26 lines
726 B
Ruby

# frozen_string_literal: true
class WebHookJob < ApplicationJob
queue_as :default
TIMEOUT = 10
def perform(procedure_id, dossier_id, state, updated_at)
body = {
procedure_id: procedure_id,
dossier_id: dossier_id,
state: state,
updated_at: updated_at
}
procedure = Procedure.find(procedure_id)
response = Typhoeus.post(procedure.web_hook_url, body: body, timeout: TIMEOUT)
if !response.success?
Sentry.set_tags(procedure: procedure_id, dossier: dossier_id)
Sentry.set_extras(web_hook_url: procedure.web_hook_url)
Sentry.capture_message("Webhook error code: #{response.code} (#{response.return_message}) // Response: #{response.body}")
end
end
end