grafana/pkg/infra/db/dbrepl.go
Kristin Laemmert 299c142f6a
QuotaService: refactor to use ReplDB for Get queries (#91333)
* Feature (quota service): Use ReplDB for quota service Gets

This adds the replDB to the quota service, as well as some more test helper functions to simplify updating tests. My intent is that the helper functions can be removed when this is fully rolled out (or not) and we're consistently using the ReplDB interface (or not!)

* test updates
2024-08-08 13:41:33 -04:00

20 lines
595 B
Go

package db
import (
"github.com/grafana/grafana/pkg/services/sqlstore"
)
type ReplDB interface {
// DB is the primary database connection.
DB() *sqlstore.SQLStore
// ReadReplica is the read-only database connection. If no read replica is configured, the implementation must return the primary DB.
ReadReplica() *sqlstore.SQLStore
}
// FakeREplDBFromDBForTests returns a ReplDB that uses the given DB as the primary connection. It's a helper function for tests.
func FakeReplDBFromDB(primary DB) ReplDB {
ss := primary.(*sqlstore.SQLStore)
return sqlstore.FakeReplStoreFromStore(ss)
}