dendrite/pushserver/storage/storage.go
Piotr Kozimor 151d52ce23 Add Pushserver component with Pushers API
Co-authored-by: Tommie Gannert <tommie@gannert.se>
Co-authored-by: Dan Peleg <dan@globekeeper.com>
2021-11-19 12:58:38 +01:00

25 lines
595 B
Go

//go:build !wasm
// +build !wasm
package storage
import (
"fmt"
"github.com/matrix-org/dendrite/pushserver/storage/postgres"
"github.com/matrix-org/dendrite/pushserver/storage/sqlite3"
"github.com/matrix-org/dendrite/setup/config"
)
// Open opens a database connection.
func Open(dbProperties *config.DatabaseOptions) (Database, error) {
switch {
case dbProperties.ConnectionString.IsSQLite():
return sqlite3.Open(dbProperties)
case dbProperties.ConnectionString.IsPostgres():
return postgres.Open(dbProperties)
default:
return nil, fmt.Errorf("unexpected database type")
}
}