mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-13 13:31:19 +00:00
23 lines
636 B
Ruby
23 lines
636 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::SessionMap
|
|
.with_sessions(Gitlab::Database::LoadBalancing.base_models)
|
|
.use_primary(&block)
|
|
end
|
|
end
|
|
end
|
|
end
|