diff --git a/common/keydb/keydb.go b/common/keydb/keydb.go index 26d3a33b7..04692e98c 100644 --- a/common/keydb/keydb.go +++ b/common/keydb/keydb.go @@ -16,6 +16,7 @@ package keydb import ( "context" + "errors" "net/url" "github.com/matrix-org/dendrite/common/keydb/postgres" @@ -32,14 +33,14 @@ type Database interface { func NewDatabase(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewDatabase(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.NewDatabase(dataSourceName) default: - // if the scheme doesn't match, fall back to postgres in case the config has - // postgres key=value connection strings - return postgres.NewDatabase(dataSourceName) + return nil, errors.New("unknown schema") } } diff --git a/federationsender/storage/storage.go b/federationsender/storage/storage.go index a632449e5..9f2805cf7 100644 --- a/federationsender/storage/storage.go +++ b/federationsender/storage/storage.go @@ -16,6 +16,7 @@ package storage import ( "context" + "errors" "net/url" "github.com/matrix-org/dendrite/common" @@ -33,14 +34,14 @@ type Database interface { func NewDatabase(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewDatabase(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.NewDatabase(dataSourceName) default: - // if the scheme doesn't match, fall back to postgres in case the config has - // postgres key=value connection strings - return postgres.NewDatabase(dataSourceName) + return errors.New("unknown schema") } } diff --git a/mediaapi/storage/storage.go b/mediaapi/storage/storage.go index 3e9e4ef6e..ca9f69f8f 100644 --- a/mediaapi/storage/storage.go +++ b/mediaapi/storage/storage.go @@ -16,6 +16,7 @@ package storage import ( "context" + "errors" "net/url" "github.com/matrix-org/dendrite/mediaapi/storage/postgres" @@ -35,14 +36,14 @@ type Database interface { func Open(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.Open(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.Open(dataSourceName) default: - // if the scheme doesn't match, fall back to postgres in case the config has - // postgres key=value connection strings - return postgres.Open(dataSourceName) + return nil, errors.New("unknown schema") } } diff --git a/publicroomsapi/storage/storage.go b/publicroomsapi/storage/storage.go index 7018507e9..d611686ba 100644 --- a/publicroomsapi/storage/storage.go +++ b/publicroomsapi/storage/storage.go @@ -16,6 +16,7 @@ package storage import ( "context" + "errors" "net/url" "github.com/matrix-org/dendrite/common" @@ -38,14 +39,14 @@ type Database interface { func NewPublicRoomsServerDatabase(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewPublicRoomsServerDatabase(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.NewPublicRoomsServerDatabase(dataSourceName) default: - // if the scheme doesn't match, fall back to postgres in case the config has - // postgres key=value connection strings - return postgres.NewPublicRoomsServerDatabase(dataSourceName) + return nil, errors.New("unknown schema") } } diff --git a/roomserver/storage/storage.go b/roomserver/storage/storage.go index 8ad2dde84..62e8b64c3 100644 --- a/roomserver/storage/storage.go +++ b/roomserver/storage/storage.go @@ -16,6 +16,7 @@ package storage import ( "context" + "errors" "net/url" "github.com/matrix-org/dendrite/roomserver/api" @@ -60,14 +61,14 @@ type Database interface { func Open(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.Open(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.Open(dataSourceName) default: - // if the scheme doesn't match, fall back to postgres in case the config has - // postgres key=value connection strings - return postgres.Open(dataSourceName) + return nil, errors.New("unknown schema") } } diff --git a/syncapi/storage/storage.go b/syncapi/storage/storage.go index de9a6bef9..4d896531a 100644 --- a/syncapi/storage/storage.go +++ b/syncapi/storage/storage.go @@ -16,6 +16,7 @@ package storage import ( "context" + "errors" "net/url" "time" @@ -51,14 +52,14 @@ type Database interface { func NewSyncServerDatasource(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewSyncServerDatasource(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.NewSyncServerDatasource(dataSourceName) default: - // if the scheme doesn't match, fall back to postgres in case the config has - // postgres key=value connection strings - return postgres.NewSyncServerDatasource(dataSourceName) + return nil, errors.New("unknown schema") } }