mirror of
https://github.com/multipleof4/ntfy.git
synced 2026-10-12 14:55:22 +00:00
Switch lib
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq" // PostgreSQL driver
|
||||
_ "github.com/jackc/pgx/v5/stdlib" // PostgreSQL driver
|
||||
|
||||
"heckel.io/ntfy/v2/util"
|
||||
)
|
||||
@@ -139,7 +139,7 @@ var _ MessageCache = (*pgMessageCache)(nil)
|
||||
|
||||
// newPgCache creates a PostgreSQL-backed message cache
|
||||
func newPgCache(connectionString, startupQueries string, batchSize int, batchTimeout time.Duration) (*pgMessageCache, error) {
|
||||
db, err := sql.Open("postgres", connectionString)
|
||||
db, err := sql.Open("pgx", connectionString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -191,4 +191,3 @@ func setupNewPgCacheDB(db *sql.DB) error {
|
||||
func isPostgres(connectionString string) bool {
|
||||
return strings.HasPrefix(connectionString, "postgres:")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -249,7 +249,7 @@ func createMessageCache(conf *Config) (MessageCache, error) {
|
||||
if conf.CacheDuration == 0 {
|
||||
return newNopCache()
|
||||
} else if isPostgres(conf.CacheFile) {
|
||||
return newPgCache(strings.TrimPrefix(conf.CacheFile, "postgres:"), conf.CacheStartupQueries, conf.CacheBatchSize, conf.CacheBatchTimeout)
|
||||
return newPgCache(conf.CacheFile, conf.CacheStartupQueries, conf.CacheBatchSize, conf.CacheBatchTimeout)
|
||||
} else if conf.CacheFile != "" {
|
||||
return newSqliteCache(conf.CacheFile, conf.CacheStartupQueries, conf.CacheDuration, conf.CacheBatchSize, conf.CacheBatchTimeout, false)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/lib/pq" // PostgreSQL driver
|
||||
_ "github.com/jackc/pgx/v5/stdlib" // PostgreSQL driver
|
||||
)
|
||||
|
||||
// PostgreSQL-specific queries
|
||||
@@ -75,7 +75,7 @@ var pgWebPushQueries = &webPushQueries{
|
||||
}
|
||||
|
||||
func newPgWebPushStore(connStr, startupQueries string) (*webPushStore, error) {
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
db, err := sql.Open("pgx", connStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user