diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-14 15:12:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-14 15:12:34 +0300 |
commit | 16daf112d6cfe2c87d8837382a00d88aa8c0ff5c (patch) | |
tree | 017d43acafea2928550fe7c8fdbb7cf36335ba9f /lib/gitlab/utils | |
parent | 3cb798d80b6b5235b5f5febaaacef410e75c2963 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/utils')
-rw-r--r-- | lib/gitlab/utils/execution_tracker.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/utils/execution_tracker.rb b/lib/gitlab/utils/execution_tracker.rb new file mode 100644 index 00000000000..6d48658853c --- /dev/null +++ b/lib/gitlab/utils/execution_tracker.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Gitlab + module Utils + class ExecutionTracker + MAX_RUNTIME = 30.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 |