Documentation ¶
Overview ¶
Package pgdfailwrap is a wrapper driver for 'postgres' drivers that adds the capability to detect a node that is in readonly mode and reject such a connection in order to be resilient to database failover from master to slave. The typical use case here is database maintenance.
Example use:
import ( "database/sql" _ "github.com/lib/pq" ) func main() { var conStrs []string conStrs = append(conStrs, fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", masterHost, masterPort, user, password, dbName)) conStrs = append(conStrs, fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", slaveHost, slavePort, user, password, dbName)) InitDriver(&pq.Driver{}) sqlDb, err := sql.Open("postgres-with-failover", strings.Join(conStrs, ",")) if err != nil { log.Fatal(err) } ... }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitDriver ¶
InitDriver initializes the wrapper driver taking an already initialized postgres driver as argument.
Types ¶
Click to show internal directories.
Click to hide internal directories.