postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, uri string) (*sql.DB, error)

Connect connects to a postgres database. This is only used in tests.

Types

type Database

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

func New

func New(ctx context.Context, puri string, version int) (*Database, error)

func (*Database) Close

func (p *Database) Close() error

func (*Database) DB

func (p *Database) DB() *sql.DB

func (*Database) RegisterNotification

func (p *Database) RegisterNotification(ctx context.Context, n database.NotificationName, f database.NotificationCallback, payload any) error

RegisterNotification registers a call back for database notifications.

Note that this currently launches a connection+go routine to listen for notifications. It may be an idea to switch this code to only launch a single go routine for all notifications.

func (*Database) UnregisterNotification

func (p *Database) UnregisterNotification(n database.NotificationName) error

Jump to

Keyboard shortcuts

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