-
eileencodes authored
Now that we have implemented granular connection swapping in #40370 we need a new API that will allow connections to multiple databases. The reason we need this API is it will prevent deep nesting in cases where we know that we want 3 of our 5 databases to connect to reading and leave the rest on writing. With this API, instead of writing: ```ruby AnimalsRecord.connected_to(role: :reading) do MealsRecord.connected_to(role: :reading) do Dog.first # read from animals replica Dinner.first # read from meals replica Person.first # read from primary writer end end ``` This API would allow you to write: ```ruby ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do Dog.first # read from animals replica Dinner.first # read from meals replica Person.first # read from primary writer end ``` This would come in especially handy for deeper nesting past 2 databases. Co-authored-by:
John Crepezzi <john.crepezzi@gmail.com>
eileencodes authoredNow that we have implemented granular connection swapping in #40370 we need a new API that will allow connections to multiple databases. The reason we need this API is it will prevent deep nesting in cases where we know that we want 3 of our 5 databases to connect to reading and leave the rest on writing. With this API, instead of writing: ```ruby AnimalsRecord.connected_to(role: :reading) do MealsRecord.connected_to(role: :reading) do Dog.first # read from animals replica Dinner.first # read from meals replica Person.first # read from primary writer end end ``` This API would allow you to write: ```ruby ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do Dog.first # read from animals replica Dinner.first # read from meals replica Person.first # read from primary writer end ``` This would come in especially handy for deeper nesting past 2 databases. Co-authored-by:
John Crepezzi <john.crepezzi@gmail.com>
Loading