Files
gitlabhq/app/workers/concerns/loop_with_runtime_limit.rb
2024-11-08 18:13:16 +00:00

15 lines
402 B
Ruby

# frozen_string_literal: true
module LoopWithRuntimeLimit # rubocop:disable Gitlab/BoundedContexts -- it's a general purpose module
private
def loop_with_runtime_limit(time_limit)
runtime_limiter = Gitlab::Metrics::RuntimeLimiter.new(time_limit)
loop do
yield runtime_limiter
break :over_time if runtime_limiter.was_over_time? || runtime_limiter.over_time?
end
end
end