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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/utils/execution_tracker.rb')
-rw-r--r--lib/gitlab/utils/execution_tracker.rb25
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