mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
299c142f6a
* 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
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)
|
|
}
|