mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
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.
31 lines
714 B
Go
31 lines
714 B
Go
//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"
|
|
}
|