Documentation ¶
Index ¶
- Variables
- type ChannelOption
- type Config
- type Conn
- func (cn *Conn) Begin() (driver.Tx, error)
- func (cn *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (cn *Conn) Close() error
- func (cn *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (cn *Conn) IsValid() bool
- func (cn *Conn) Ping(ctx context.Context) error
- func (cn *Conn) Prepare(query string) (driver.Stmt, error)
- func (cn *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type Connector
- type Driver
- type DriverOption
- func WithAddr(addr string) DriverOption
- func WithApplicationName(appName string) DriverOption
- func WithDSN(dsn string) DriverOption
- func WithDatabase(database string) DriverOption
- func WithDialTimeout(dialTimeout time.Duration) DriverOption
- func WithPassword(password string) DriverOption
- func WithReadTimeout(readTimeout time.Duration) DriverOption
- func WithTLSConfig(cfg *tls.Config) DriverOption
- func WithTimeout(timeout time.Duration) DriverOption
- func WithUser(user string) DriverOption
- func WithWriteTimeout(writeTimeout time.Duration) DriverOption
- type DriverStats
- type Error
- type Listener
- func (ln *Listener) Channel(opts ...ChannelOption) <-chan Notification
- func (ln *Listener) Close() error
- func (ln *Listener) Listen(ctx context.Context, channels ...string) error
- func (ln *Listener) Receive(ctx context.Context) (channel string, payload string, err error)
- func (ln *Listener) ReceiveTimeout(ctx context.Context, timeout time.Duration) (channel, payload string, err error)
- func (ln *Listener) Unlisten(ctx context.Context, channels ...string) error
- type Notification
Constants ¶
This section is empty.
Variables ¶
var Logger logging = &logger{ log: log.New(os.Stderr, "pgdriver: ", log.LstdFlags|log.Lshortfile), }
Functions ¶
This section is empty.
Types ¶
type ChannelOption ¶
type ChannelOption func(c *channel)
func WithChannelSize ¶
func WithChannelSize(size int) ChannelOption
type Config ¶ added in v0.1.3
type Config struct { // Network type, either tcp or unix. // Default is tcp. Network string // TCP host:port or Unix socket depending on Network. Addr string // Dial timeout for establishing new connections. // Default is 5 seconds. DialTimeout time.Duration // Dialer creates new network connection and has priority over // Network and Addr options. Dialer func(ctx context.Context, network, addr string) (net.Conn, error) // TLS config for secure connections. TLSConfig *tls.Config User string Password string Database string AppName string // Timeout for socket reads. If reached, commands will fail // with a timeout instead of blocking. ReadTimeout time.Duration // Timeout for socket writes. If reached, commands will fail // with a timeout instead of blocking. WriteTimeout time.Duration }
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) ExecContext ¶
type Connector ¶ added in v0.3.7
type Connector struct {
// contains filtered or unexported fields
}
func NewConnector ¶
func NewConnector(opts ...DriverOption) *Connector
func (*Connector) Stats ¶ added in v0.3.7
func (d *Connector) Stats() DriverStats
type DriverOption ¶
type DriverOption func(*Connector)
func WithAddr ¶
func WithAddr(addr string) DriverOption
func WithApplicationName ¶
func WithApplicationName(appName string) DriverOption
func WithDSN ¶
func WithDSN(dsn string) DriverOption
func WithDatabase ¶
func WithDatabase(database string) DriverOption
func WithDialTimeout ¶
func WithDialTimeout(dialTimeout time.Duration) DriverOption
func WithPassword ¶
func WithPassword(password string) DriverOption
func WithReadTimeout ¶
func WithReadTimeout(readTimeout time.Duration) DriverOption
func WithTLSConfig ¶ added in v0.2.4
func WithTLSConfig(cfg *tls.Config) DriverOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) DriverOption
func WithUser ¶
func WithUser(user string) DriverOption
func WithWriteTimeout ¶
func WithWriteTimeout(writeTimeout time.Duration) DriverOption
type DriverStats ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error returned by PostgreSQL server using PostgreSQL ErrorResponse protocol.
https://www.postgresql.org/docs/current/static/protocol-message-formats.html
func (Error) Field ¶
Field returns a string value associated with an error field.
https://www.postgresql.org/docs/current/static/protocol-error-fields.html
func (Error) IntegrityViolation ¶
IntegrityViolation reports whether an error is a part of Integrity Constraint Violation class of errors.
https://www.postgresql.org/docs/current/static/errcodes-appendix.html
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
func (*Listener) Channel ¶
func (ln *Listener) Channel(opts ...ChannelOption) <-chan Notification
Channel returns a channel for concurrently receiving notifications. It periodically sends Ping notification to test connection health.
The channel is closed with Listener. Receive* APIs can not be used after channel is created.
func (*Listener) Receive ¶
Receive indefinitely waits for a notification. This is low-level API and in most cases Channel should be used instead.
type Notification ¶
Notification received with LISTEN command.