mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2025-08-01 16:46:16 +00:00
15 lines
402 B
Ruby
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
|