postgresql

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2020 License: BSD-3-Clause Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// DriverName for postgres driver
	DriverName = "postgres"
	// MasterQuery returns true when not in recovery (means node is master)
	MasterQuery = "select not pg_is_in_recovery();"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Nodes  []Node `json:"nodes,omitempty"`
	Params Params `json:"params,omitempty"`
}

Config for postgreSQL drivers. Multiple Nodes will use the same set of params.

func (Config) DataSourceNames

func (c Config) DataSourceNames() (dsns []string)

DataSourceNames implements driver.Configurator

func (Config) DriverName

func (Config) DriverName() string

DriverName returns the DriverName constant. Implements driver.Configurator

func (Config) MasterQuery

func (Config) MasterQuery() string

MasterQuery returns the MasterQuery constant. Implements driver.Configurator

func (Config) WhiteList

func (Config) WhiteList(err error) bool

WhiteList returns true if the passed error is not a connection on DB consistency error. It used pq error codes for checking

type Node added in v0.1.1

type Node struct {
	Host string `json:"host,omitempty"` // The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
	Port uint16 `json:"port,omitempty"` // The port to bind to. (default is 5432)
}

Node holds the address and port information for a single DB Node

type Params added in v0.1.1

type Params struct {
	DBname                    string  `json:"dbname,omitempty"`                    // The name of the database to connect to
	User                      string  `json:"user,omitempty"`                      // The user to sign in as
	Password                  string  `json:"password,omitempty"`                  // The user's password
	SSLmode                   SSLMode `json:"sslmode,omitempty"`                   // Whether or not to use SSL (default is require, this is not the default for libpq)
	Fallback_application_name string  `json:"fallback_application_name,omitempty"` // An application_name to fall back to if one isn't provided.
	Connect_timeout           uint    `json:"connect_timeout,omitempty"`           // Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
	SSLcert                   string  `json:"sslcert,omitempty"`                   // Cert file location. The file must contain PEM encoded data.
	SSLkey                    string  `json:"sslkey,omitempty"`                    // Key file location. The file must contain PEM encoded data.
	SSLrootcert               string  `json:"sslrootcert,omitempty"`               // The location of the root certificate file. The file must contain PEM encoded data.
}

Params holds all remaining pq settings, as defined at https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters

type SSLMode added in v0.1.1

type SSLMode string

SSLMode used for connection

const (
	// SSLDisable means: No SSL
	SSLDisable SSLMode = "disable"
	// SSLRequire means: Always SSL
	// (skip verification)
	SSLRequire SSLMode = "require"
	// SSLVerifyCA means: Always SSL
	// (verify that the certificate presented by the server was signed by a trusted CA)
	SSLVerifyCA SSLMode = "verify-ca"
	// SSLVerifyFull means: Always SSL
	// (verify that the certification presented by the server was signed by a trusted CA
	// and the server host name matches the one in the certificate)
	SSLVerifyFull SSLMode = "verify-full"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL