-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(database): add optional build support for SQLite
Miniflux can be build with `go build -tags=sqlite` to test this. Note that while it builds, it will fail at runtime, as some of the SQL used in miniflux is postgresql-specific.
- Loading branch information
Showing
5 changed files
with
62 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build !sqlite | ||
|
||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package database // import "miniflux.app/v2/internal/database" | ||
|
||
import ( | ||
"database/sql" | ||
"time" | ||
|
||
_ "github.com/lib/pq" | ||
) | ||
|
||
// NewConnectionPool configures the database connection pool. | ||
func NewConnectionPool(dsn string, minConnections, maxConnections int, connectionLifetime time.Duration) (*sql.DB, error) { | ||
db, err := sql.Open("postgres", dsn) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
db.SetMaxOpenConns(maxConnections) | ||
db.SetMaxIdleConns(minConnections) | ||
db.SetConnMaxLifetime(connectionLifetime) | ||
|
||
return db, nil | ||
} | ||
|
||
func getDriverStr() string { | ||
return "postgresql" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//go:build sqlite | ||
|
||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package database // import "miniflux.app/v2/internal/database" | ||
|
||
import ( | ||
"database/sql" | ||
"time" | ||
|
||
_ "github.com/mattn/go-sqlite3" | ||
) | ||
|
||
// NewConnectionPool configures the database connection pool. | ||
func NewConnectionPool(dsn string, _, _ int, _ time.Duration) (*sql.DB, error) { | ||
db, err := sql.Open("sqlite3", dsn) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return db, nil | ||
} | ||
|
||
func getDriverStr() string { | ||
return "sqlite3" | ||
} |