gitlab-org--gitlab-foss/lib/gitlab/database/consistency.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
571 B
Ruby
Raw Normal View History

# 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