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

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

module Gitlab
  module Database
    ##
    # This class is used to make it possible to ensure read consistency in
    # GitLab without the need of overriding a lot of methods / classes /
    # classs.
    #
    class Consistency
      ##
      # Within the block, disable the database load balancing for calls that
      # require read consistency after recent writes.
      #
      def self.with_read_consistency(&block)
        ::Gitlab::Database::LoadBalancing::Session
          .current.use_primary(&block)
      end
    end
  end
end