Use pointer when passing the connection manager around (#3152)
As otherwise existing connections aren't reused.
This commit is contained in:
parent
a01faee17c
commit
297479ea49
31 changed files with 143 additions and 79 deletions
|
|
@ -59,14 +59,14 @@ type DB struct {
|
|||
}
|
||||
|
||||
// NewDatabase loads the database for msc2836
|
||||
func NewDatabase(conMan sqlutil.Connections, dbOpts *config.DatabaseOptions) (Database, error) {
|
||||
func NewDatabase(conMan *sqlutil.Connections, dbOpts *config.DatabaseOptions) (Database, error) {
|
||||
if dbOpts.ConnectionString.IsPostgres() {
|
||||
return newPostgresDatabase(conMan, dbOpts)
|
||||
}
|
||||
return newSQLiteDatabase(conMan, dbOpts)
|
||||
}
|
||||
|
||||
func newPostgresDatabase(conMan sqlutil.Connections, dbOpts *config.DatabaseOptions) (Database, error) {
|
||||
func newPostgresDatabase(conMan *sqlutil.Connections, dbOpts *config.DatabaseOptions) (Database, error) {
|
||||
d := DB{}
|
||||
var err error
|
||||
if d.db, d.writer, err = conMan.Connection(dbOpts); err != nil {
|
||||
|
|
@ -144,7 +144,7 @@ func newPostgresDatabase(conMan sqlutil.Connections, dbOpts *config.DatabaseOpti
|
|||
return &d, err
|
||||
}
|
||||
|
||||
func newSQLiteDatabase(conMan sqlutil.Connections, dbOpts *config.DatabaseOptions) (Database, error) {
|
||||
func newSQLiteDatabase(conMan *sqlutil.Connections, dbOpts *config.DatabaseOptions) (Database, error) {
|
||||
d := DB{}
|
||||
var err error
|
||||
if d.db, d.writer, err = conMan.Connection(dbOpts); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue