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/render_timeout.rb')
-rw-r--r--lib/gitlab/render_timeout.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/render_timeout.rb b/lib/gitlab/render_timeout.rb
new file mode 100644
index 00000000000..b3c2a5b4c2a
--- /dev/null
+++ b/lib/gitlab/render_timeout.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module RenderTimeout
+ BACKGROUND = 30.seconds
+ FOREGROUND = 1.5.seconds
+
+ def self.timeout(background: BACKGROUND, foreground: FOREGROUND, &block)
+ period = Gitlab::Runtime.sidekiq? ? background : foreground
+
+ Timeout.timeout(period, &block)
+ end
+ end
+end