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/rack_load_balancing_helpers.rb')
-rw-r--r--lib/gitlab/rack_load_balancing_helpers.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/rack_load_balancing_helpers.rb b/lib/gitlab/rack_load_balancing_helpers.rb
new file mode 100644
index 00000000000..5d7228a38fd
--- /dev/null
+++ b/lib/gitlab/rack_load_balancing_helpers.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module RackLoadBalancingHelpers
+ def load_balancer_stick_request(model, namespace, id)
+ request.env[::Gitlab::Database::LoadBalancing::RackMiddleware::STICK_OBJECT] ||= Set.new
+ request.env[::Gitlab::Database::LoadBalancing::RackMiddleware::STICK_OBJECT] << [model.sticking, namespace, id]
+
+ model
+ .sticking
+ .find_caught_up_replica(namespace, id)
+ end
+ end
+end