I wasn't able to get the time, so I couldn't make FreshConnection compatible with Rails 6. In Japan, we have entered a long vacation season. Of course, I must stay home, so I spended most of my time playing with my daughter. I took refuge in my study room. So I was able to develop a FreshConnection.
FreshConnection version released is 3.1.0.
This version of Fresh Connection has not been tested with Rails 6's Multiple Database. It may or may not work well. Therefore, please refrain from using it together. In the next version, I plan to implement FreshConnection using the functionality of Rails 6's Multiple Database. Also, the interface may change accordingly.
Introducing the function of FreshConnection again
FreshConnection adds to ActiveRecord the ability to access read replicas. If only that, you should use Rails 6's Multiple Database. FreshConnection's focus is on how to access read replicas.
Article.take Article.where(id: 1) Account.count
Read queries are automatically connected to the DB replica.
Article.create(title: "ok") a = Article.take a.title << "hoge" a.save! a.destroy
Write queries are automatically connected to the DB master.
Article.transaction do Article.take end
Within transactions, all queries are connected to the DB master.
FreshConnection will be able to access read replicas without changing your existing code. You can develop Rails applications without worrying about accessing replicas. Of course, it doesn't combine with Controller like Rails6's Multiple Database.
This is what FreshConnection values most.