2020-01-24 07:09:01 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module SidekiqMiddleware
|
|
|
|
module WorkerContext
|
|
|
|
class Server
|
2020-01-31 04:08:53 -05:00
|
|
|
include Gitlab::SidekiqMiddleware::WorkerContext
|
|
|
|
|
2020-01-24 07:09:01 -05:00
|
|
|
def call(worker, job, _queue, &block)
|
|
|
|
worker_class = worker.class
|
|
|
|
|
|
|
|
# This is not a worker we know about, perhaps from a gem
|
|
|
|
return yield unless worker_class.respond_to?(:get_worker_context)
|
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
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-01-24 07:09:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|