Welcome to mirror list, hosted at ThFree Co, Russian Federation.

execution_tracker.rb « utils « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 92398926e1b5b4f531ed69a1707118a83448cb86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Gitlab
  module Utils
    class ExecutionTracker
      MAX_RUNTIME = 60.seconds

      ExecutionTimeOutError = Class.new(StandardError)

      delegate :monotonic_time, to: :'Gitlab::Metrics::System'

      def initialize
        @start_time = monotonic_time
      end

      def over_limit?
        monotonic_time - start_time >= MAX_RUNTIME
      end

      private

      attr_reader :start_time
    end
  end
end