mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 09:43:10 -06:00
Co-authored-by: Tommie Gannert <tommie@gannert.se> Co-authored-by: Dan Peleg <dan@globekeeper.com>
25 lines
595 B
Go
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")
|
|
}
|
|
}
|