• Yorick Peterse's avatar
    Prepare LoadBalancer for multiple databases · 0a4e9841
    Yorick Peterse authored
    This refactors Gitlab::Database::LoadBalancing::LoadBalancer so it can
    support the use of multiple databases (each with their own load
    balancer) in the future.
    
    Instead of directly depending on ActiveRecord::Base, LoadBalancer now
    takes a ActiveRecord model. It will then scope its work to that model,
    including the data that it caches in RequestStore. This ensures two
    different LoadBalancer instances won't conflict with each other.
    
    The new setup of retrieving connections is such that we can ensure we
    always have the right connection (e.g. a writable connection when we
    need one).
    
    See https://gitlab.com/gitlab-org/gitlab/-/issues/331776 for more
    information.
    Co-Authored-By: default avatarThong Kuah <tkuah@gitlab.com>
    0a4e9841
load_balancer.rb 8.07 KB