If configured, most archiving, live, and archive reading queries (when browser archiving is disabled) will be read from a reader instead of the master. This means mainly the tracker will hit the master database and when writing archives.
FYI added a system check that connection works if a reader is configured.
Tested it locally and worked quite well. Also adjusted all our premium features to use
VisitorDetailsAbstract::getDb() // in a BC way so in the future the core can easily decide/control whether to use reader or master etc.
Once I get the OK will give it a test on a different Matomo.
Didn't look at the code in details but the idea sounds great! Many users will have slave databases running doing nothing and this is a great way to leverage this valuable CPU.
Just wondering, what happens if the reader goes down, would it maybe help to full back to master automatically or is it better to fail explicitly?
Edit: it would be great to document this feature in an faq
For now it would just fail. Would otherwise need a lot of extra code etc. It's just to get a quick win. Later you can at some point do a lot more with it.
Maybe we could merge this feature already? Considering it will use regular DB if no reader is defined it shouldn't change anything. Can also patch this later though.
Code looks good to me, seems ok to merge to me