mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-03-18 21:30:44 +01:00
26 lines
580 B
Go
26 lines
580 B
Go
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"sync/atomic"
|
|
)
|
|
|
|
// Beginner is an interface for types that can begin a database transaction.
|
|
// Both *sql.DB and *DB implement this.
|
|
type Beginner interface {
|
|
Begin() (*sql.Tx, error)
|
|
}
|
|
|
|
// Querier is an interface for types that can execute SQL queries.
|
|
// *sql.DB, *sql.Tx, and *DB all implement this.
|
|
type Querier interface {
|
|
Query(query string, args ...any) (*sql.Rows, error)
|
|
}
|
|
|
|
// Host pairs a *sql.DB with the host:port it was opened against.
|
|
type Host struct {
|
|
Addr string // "host:port"
|
|
DB *sql.DB
|
|
healthy atomic.Bool
|
|
}
|