postgres

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual added in v0.1.37

func AreEqual(c *ClientConfig, d *ClientConfig) bool

AreEqual returns true iff the two configurations are equal.

func Open added in v0.1.37

Open opens a connection to a PostgreSQL database.

Types

type ClientConfig

type ClientConfig struct {
	AppName        string   // The application name to identify ourselves as. This may appear in any logs PostgreSQL produces.
	Hosts          []string // The hosts
	Username       string   // The user to sign in as
	Password       string   // The user's password
	PasswordSet    bool     // Is a password set?
	ConnectTimeout int      // Maximum wait for connection, in seconds. Zero means wait indefinitely.
	RequireSSL     bool     // Whether or not to require SSL
	FastCopy       bool     // Whether to support PostgreSQL's COPY commands
}

ClientConfig describes the configuration options we allow a user to set on a client connection.

Hosts: If a host name begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored.

FastCopy: If enabled, the COPY command will be used to perform inserts. Note that, with the citus extension for sharded tables enabled, the COPY command opens up one connection per shard (see http://docs.citusdata.com/en/v8.2/reference/common_errors.html). If you run M concurrent copies into a destination with N shards, that will result in M*N connections. In this circumstance you probably want to disable the COPY command, as it is likely to exhaust the number of available connections.

func DefaultConfig

func DefaultConfig() *ClientConfig

DefaultConfig returns a new client configuration initialised with the default values.

The initial default value for the hosts, username, and password will be read from the environment variables

PCAS_POSTGRES_HOST = "hostname1[:port1][,...,hostnamek[:portk]]"
PCAS_POSTGRES_USERNAME = "myname"
PCAS_POSTGRES_PASSWORD = "mysecret"

respectively on package init.

Note that if PCAS_POSTGRES_PASSWORD is set but with value equal to the empty string then it still counts as a valid password, since the empty string is a valid password. You must ensure that PCAS_POSTGRES_PASSWORD is unset if you do not want to specify an initial default password.

func SetDefaultConfig

func SetDefaultConfig(c *ClientConfig) *ClientConfig

SetDefaultConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultConfig.

func (*ClientConfig) Copy

func (c *ClientConfig) Copy() *ClientConfig

Copy returns a copy of the configuration.

func (*ClientConfig) Hash added in v0.1.37

func (c *ClientConfig) Hash() uint32

Hash returns a hash for the configuration.

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

Validate validates the client configuration, returning an error if there's a problem.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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