Route authorization query to read-only database replica to reduce primary database load

This commit is contained in:
binwiederhier
2026-03-15 22:01:19 -04:00
parent f5c255c53c
commit 6b38acb23a
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -642,7 +642,7 @@ func (a *Manager) AllowReservation(username string, topic string) error {
// - Furthermore, the query prioritizes more specific permissions (longer!) over more generic ones, e.g. "test*" > "*"
// - It also prioritizes write permissions over read permissions
func (a *Manager) authorizeTopicAccess(usernameOrEveryone, topic string) (read, write, found bool, err error) {
rows, err := a.db.Query(a.queries.selectTopicPerms, Everyone, usernameOrEveryone, topic)
rows, err := a.db.ReadOnly().Query(a.queries.selectTopicPerms, Everyone, usernameOrEveryone, topic)
if err != nil {
return false, false, false, err
}