mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
Fix behaviour so that it really tries postgres when URL parsing fails and it complains about unknown schema if it succeeds
This commit is contained in:
parent
feef9c124c
commit
6ab581c2af
|
|
@ -16,6 +16,7 @@ package keydb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common/keydb/postgres"
|
"github.com/matrix-org/dendrite/common/keydb/postgres"
|
||||||
|
|
@ -32,14 +33,14 @@ type Database interface {
|
||||||
func NewDatabase(dataSourceName string) (Database, error) {
|
func NewDatabase(dataSourceName string) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
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 {
|
switch uri.Scheme {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return postgres.NewDatabase(dataSourceName)
|
return postgres.NewDatabase(dataSourceName)
|
||||||
default:
|
default:
|
||||||
// if the scheme doesn't match, fall back to postgres in case the config has
|
return nil, errors.New("unknown schema")
|
||||||
// postgres key=value connection strings
|
|
||||||
return postgres.NewDatabase(dataSourceName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
|
@ -33,14 +34,14 @@ type Database interface {
|
||||||
func NewDatabase(dataSourceName string) (Database, error) {
|
func NewDatabase(dataSourceName string) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
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 {
|
switch uri.Scheme {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return postgres.NewDatabase(dataSourceName)
|
return postgres.NewDatabase(dataSourceName)
|
||||||
default:
|
default:
|
||||||
// if the scheme doesn't match, fall back to postgres in case the config has
|
return errors.New("unknown schema")
|
||||||
// postgres key=value connection strings
|
|
||||||
return postgres.NewDatabase(dataSourceName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/mediaapi/storage/postgres"
|
"github.com/matrix-org/dendrite/mediaapi/storage/postgres"
|
||||||
|
|
@ -35,14 +36,14 @@ type Database interface {
|
||||||
func Open(dataSourceName string) (Database, error) {
|
func Open(dataSourceName string) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
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 {
|
switch uri.Scheme {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return postgres.Open(dataSourceName)
|
return postgres.Open(dataSourceName)
|
||||||
default:
|
default:
|
||||||
// if the scheme doesn't match, fall back to postgres in case the config has
|
return nil, errors.New("unknown schema")
|
||||||
// postgres key=value connection strings
|
|
||||||
return postgres.Open(dataSourceName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
|
@ -38,14 +39,14 @@ type Database interface {
|
||||||
func NewPublicRoomsServerDatabase(dataSourceName string) (Database, error) {
|
func NewPublicRoomsServerDatabase(dataSourceName string) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
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 {
|
switch uri.Scheme {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return postgres.NewPublicRoomsServerDatabase(dataSourceName)
|
return postgres.NewPublicRoomsServerDatabase(dataSourceName)
|
||||||
default:
|
default:
|
||||||
// if the scheme doesn't match, fall back to postgres in case the config has
|
return nil, errors.New("unknown schema")
|
||||||
// postgres key=value connection strings
|
|
||||||
return postgres.NewPublicRoomsServerDatabase(dataSourceName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
|
@ -60,14 +61,14 @@ type Database interface {
|
||||||
func Open(dataSourceName string) (Database, error) {
|
func Open(dataSourceName string) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
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 {
|
switch uri.Scheme {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return postgres.Open(dataSourceName)
|
return postgres.Open(dataSourceName)
|
||||||
default:
|
default:
|
||||||
// if the scheme doesn't match, fall back to postgres in case the config has
|
return nil, errors.New("unknown schema")
|
||||||
// postgres key=value connection strings
|
|
||||||
return postgres.Open(dataSourceName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -51,14 +52,14 @@ type Database interface {
|
||||||
func NewSyncServerDatasource(dataSourceName string) (Database, error) {
|
func NewSyncServerDatasource(dataSourceName string) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
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 {
|
switch uri.Scheme {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return postgres.NewSyncServerDatasource(dataSourceName)
|
return postgres.NewSyncServerDatasource(dataSourceName)
|
||||||
default:
|
default:
|
||||||
// if the scheme doesn't match, fall back to postgres in case the config has
|
return nil, errors.New("unknown schema")
|
||||||
// postgres key=value connection strings
|
|
||||||
return postgres.NewSyncServerDatasource(dataSourceName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue