1247fba905
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
(cherry picked from commit 299c142f6a)
Co-authored-by: Kristin Laemmert <mildwonkey@users.noreply.github.com>
20 lines
595 B
Go
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)
|
|
}
|