aboutsummaryrefslogtreecommitdiff
path: root/federationsender/storage
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-01-09 17:03:36 +0000
committerGitHub <noreply@github.com>2020-01-09 17:03:36 +0000
commit714959126beca3a85bac0bd0e8be2e20e8cf8c84 (patch)
treeacd5e0ebbaceff749fdbfe088a707fb6697b6974 /federationsender/storage
parentf7faf74528e1508f43d8d3705c6982b822bb3e9b (diff)
Fall back to postgres when database connection string parsing fails (#842)
* Fall back to postgres when parsing the database connection string for a URI schema fails * Fix behaviour so that it really tries postgres when URL parsing fails and it complains about unknown schema if it succeeds
Diffstat (limited to 'federationsender/storage')
-rw-r--r--federationsender/storage/storage.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/federationsender/storage/storage.go b/federationsender/storage/storage.go
index 8cffdbf1..9f2805cf 100644
--- a/federationsender/storage/storage.go
+++ b/federationsender/storage/storage.go
@@ -34,12 +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:
- return nil, errors.New("unknown schema")
+ return errors.New("unknown schema")
}
}