debian-mirror-gitlab/lib/gitlab/database/consistency.rb
2021-09-04 02:52:04 +05:30

21 lines
571 B
Ruby

# 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