Class: WebHookWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/web_hook_worker.rb

Overview

Worker cannot be idempotent: gitlab.com/gitlab-org/gitlab/-/issues/218559 rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(hook_id, data, hook_name, params = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/workers/web_hook_worker.rb', line 16

def perform(hook_id, data, hook_name, params = {})
  hook = WebHook.find_by_id(hook_id)
  return unless hook

  data = data.with_indifferent_access
  params.symbolize_keys!

  # Before executing the hook, reapply any recursion detection UUID that was initially
  # present in the request header so the hook can pass this same header value in its request.
  Gitlab::WebHooks::RecursionDetection.set_request_uuid(params[:recursion_detection_request_uuid])

  WebHookService.new(hook, data, hook_name, jid).execute.tap do |response|
    (:response_status, response.status)
    (:http_status, response[:http_status])
  end
end