debian-mirror-gitlab/lib/gitlab/sidekiq_middleware/worker_context/server.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
750 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module Gitlab
module SidekiqMiddleware
module WorkerContext
class Server
include Gitlab::SidekiqMiddleware::WorkerContext
def call(worker, job, _queue, &block)
2021-11-18 22:05:49 +05:30
worker_class = find_worker(worker.class, job)
2020-03-13 15:44:24 +05:30
# This is not a worker we know about, perhaps from a gem
return yield unless worker_class.respond_to?(:get_worker_context)
2021-01-03 14:25:43 +05:30
Gitlab::ApplicationContext.with_context(feature_category: worker_class.get_feature_category.to_s) do
# Use the context defined on the class level as the more specific context
wrap_in_optional_context(worker_class.get_worker_context, &block)
end
2020-03-13 15:44:24 +05:30
end
end
end
end
end