Class: Gitlab::SidekiqMiddleware::ConcurrencyLimit::MiddlewareV2
- Inherits:
-
Object
- Object
- Gitlab::SidekiqMiddleware::ConcurrencyLimit::MiddlewareV2
- Defined in:
- lib/gitlab/sidekiq_middleware/concurrency_limit/middleware_v2.rb
Instance Method Summary collapse
-
#initialize(worker, job) ⇒ MiddlewareV2
constructor
A new instance of MiddlewareV2.
-
#perform ⇒ Object
This will continue the server middleware chain if the job should be executed.
-
#schedule ⇒ Object
This will continue the middleware chain if the job should be scheduled It will return false if the job needs to be cancelled.
Constructor Details
#initialize(worker, job) ⇒ MiddlewareV2
Returns a new instance of MiddlewareV2.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gitlab/sidekiq_middleware/concurrency_limit/middleware_v2.rb', line 7 def initialize(worker, job) @worker = worker @job = job @worker_class = if worker.is_a?(Class) worker elsif worker.is_a?(String) worker.safe_constantize else worker.class end @worker_name = worker_class ? worker_class.name : nil end |
Instance Method Details
#perform ⇒ Object
This will continue the server middleware chain if the job should be executed. It will return false if the job should not be executed.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/sidekiq_middleware/concurrency_limit/middleware_v2.rb', line 36 def perform if should_defer_perform? defer_job! return end track_execution_start yield ensure track_execution_end end |
#schedule ⇒ Object
This will continue the middleware chain if the job should be scheduled It will return false if the job needs to be cancelled
24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/sidekiq_middleware/concurrency_limit/middleware_v2.rb', line 24 def schedule if should_defer_schedule? defer_job! return end yield end |