sqlutil

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuoteID

func QuoteID(parts ...string) string

Types

type BoolArray

type BoolArray []bool

func (*BoolArray) Scan

func (s *BoolArray) Scan(src interface{}) error

func (BoolArray) Value

func (s BoolArray) Value() (driver.Value, error)

type ConfigConnector

type ConfigConnector pgx.ConnConfig

ConfigConnector implements the Connector interface for a `pgx.ConnConfig`.

func (ConfigConnector) Connect

func (cfg ConfigConnector) Connect(ctx context.Context) (*pgx.Conn, error)

Connect will get a new connection using the underlying `pgx.ConnConfig`.

type Connector

type Connector interface {
	Connect(context.Context) (*pgx.Conn, error)
}

Connector will return a new *pgx.Conn.

type DBConnector

type DBConnector sql.DB

DBConnector implements the Connector and Releaser interfaces for a *sql.DB.

func (*DBConnector) Connect

func (db *DBConnector) Connect(context.Context) (*pgx.Conn, error)

Connect will return a *pgx.Conn from the underlying *sql.DB pool.

func (*DBConnector) Release

func (db *DBConnector) Release(conn *pgx.Conn) error

Release will release a *pgx.Conn to the underlying *sql.DB pool.

type Error

type Error struct {
	Code           string
	Message        string
	Detail         string
	Hint           string
	TableName      string
	ConstraintName string
	Where          string
	ColumnName     string
	Position       int
	// contains filtered or unexported fields
}

Error represents a driver-agnostic SQL error.

func MapError

func MapError(err error) *Error

MapError will return a Error from the given err object or nil otherwise.

func (Error) Error

func (e Error) Error() string

type IntArray

type IntArray []int

func (*IntArray) Scan

func (a *IntArray) Scan(src interface{}) error

func (IntArray) Value

func (a IntArray) Value() (driver.Value, error)

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener will listen for NOTIFY commands on a set of channels.

func NewListener

func NewListener(ctx context.Context, db Connector, channels ...string) (*Listener, error)

NewListener will create and initialize a Listener which will automatically reconnect and listen to the provided channels.

func (*Listener) Close

func (l *Listener) Close() error

Close performs a shutdown with a background context.

func (*Listener) Errors

func (l *Listener) Errors() <-chan error

Errors will return a channel that will be fed errors from this listener.

func (*Listener) Notifications

func (l *Listener) Notifications() <-chan *pgconn.Notification

Notifications returns the notification channel for this listener. Nil values will not be returned until the listener is closed.

func (*Listener) Shutdown added in v0.25.0

func (l *Listener) Shutdown(context.Context) error

Shutdown will shut down the listener and returns after all connections have been completed. It is not necessary to call Stop() before Close().

func (*Listener) Start

func (l *Listener) Start()

Start will enable reconnections and messages.

func (*Listener) Stop

func (l *Listener) Stop()

Stop will end all current connections and stop reconnecting.

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not null
}

func (*NullTime) Scan

func (n *NullTime) Scan(src interface{}) error

func (NullTime) Value

func (n NullTime) Value() (driver.Value, error)

type NullUUID added in v0.28.0

type NullUUID struct {
	UUID  uuid.UUID
	Valid bool
}

func (*NullUUID) Scan added in v0.28.0

func (u *NullUUID) Scan(src interface{}) (err error)

func (NullUUID) Value added in v0.28.0

func (u NullUUID) Value() (driver.Value, error)

type NullUUIDArray added in v0.28.0

type NullUUIDArray struct {
	UUIDArray UUIDArray
	Valid     bool
}

func (*NullUUIDArray) Scan added in v0.28.0

func (s *NullUUIDArray) Scan(src interface{}) error

func (NullUUIDArray) Value added in v0.28.0

func (s NullUUIDArray) Value() (driver.Value, error)

type Releaser

type Releaser interface {
	Release(*pgx.Conn) error
}

Releaser is an optional interface with a Release method to be called after a connection is closed.

type StringArray

type StringArray []string

func (*StringArray) Scan

func (s *StringArray) Scan(src interface{}) error

func (StringArray) Value

func (s StringArray) Value() (driver.Value, error)

type UUIDArray

type UUIDArray []string

func (*UUIDArray) Scan

func (s *UUIDArray) Scan(src interface{}) error

func (UUIDArray) Value

func (s UUIDArray) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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