database

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenToNotifications

func ListenToNotifications(ctx context.Context, pool PgxPool, channel string, handleFunc func(notification *pgconn.Notification))

ListenToNotifications listens for notifications on a PostgreSQL channel and triggers a handler function when a notification is received.

Types

type MockConn

type MockConn struct {
	mock.Mock
}

MockConn is a mock implementation of the Conn interface.

func (*MockConn) Exec

func (m *MockConn) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

func (*MockConn) Release

func (m *MockConn) Release()

func (*MockConn) WaitForNotification

func (m *MockConn) WaitForNotification(ctx context.Context) (*pgconn.Notification, error)

type MockPool

type MockPool struct {
	mock.Mock
}

MockPool is a mock implementation of the Pool interface.

func (*MockPool) Acquire

func (m *MockPool) Acquire(ctx context.Context) (PgxConn, error)

func (*MockPool) Close

func (m *MockPool) Close()

func (*MockPool) Exec

func (m *MockPool) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

func (*MockPool) Query

func (m *MockPool) Query(ctx context.Context, sql string, arguments ...interface{}) (pgx.Rows, error)

func (*MockPool) QueryRow

func (m *MockPool) QueryRow(ctx context.Context, sql string, arguments ...interface{}) pgx.Row

type MockRow

type MockRow struct {
	mock.Mock
	pgx.Row
}

MockRow is a mock implementation of pgx.Row.

func (*MockRow) Scan

func (m *MockRow) Scan(dest ...interface{}) error

type MockRows

type MockRows struct {
	mock.Mock
	pgx.Rows
}

MockRows is a mock implementation of pgx.Rows.

func (*MockRows) Close

func (m *MockRows) Close()

func (*MockRows) Err

func (m *MockRows) Err() error

func (*MockRows) Next

func (m *MockRows) Next() bool

func (*MockRows) Scan

func (m *MockRows) Scan(dest ...interface{}) error

type PgxConn

type PgxConn interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	WaitForNotification(ctx context.Context) (*pgconn.Notification, error)
	Release()
}

PgxConn defines the interface for a connection.

type PgxPool

type PgxPool interface {
	Acquire(ctx context.Context) (PgxConn, error)
	Close()
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, arguments ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, arguments ...interface{}) pgx.Row
}

PgxPool defines the interface for a connection pool.

func NewPGXPoolWrapper

func NewPGXPoolWrapper(pool *pgxpool.Pool) PgxPool

NewPGXPoolWrapper creates a new PGXPoolWrapper with the given pool.

Jump to

Keyboard shortcuts

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