postgres

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingOptionPool = errors.New("missing option: pool")

Functions

This section is empty.

Types

type Datastore

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

func NewDatastore

func NewDatastore(options ...DatastoreOption) (*Datastore, error)

func (*Datastore) Retrieve

func (d *Datastore) Retrieve(ctx context.Context, name, version, distributor string) (oslc.Entry, error)

func (*Datastore) Save

func (d *Datastore) Save(ctx context.Context, entry oslc.Entry) error

type DatastoreOption

type DatastoreOption interface {
	// contains filtered or unexported methods
}

func WithLogger

func WithLogger(logger *slog.Logger) DatastoreOption

func WithPool

func WithPool(pool Pool) DatastoreOption

type Pool

type Pool interface {
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	Begin(ctx context.Context) (pgx.Tx, error)
	Close()
}

Pool is an interface for a database pool. It's sole purpose is to abstract away the underlying implementation and allow for easy mocking, thus facilitating unit testutils. The NewPool function is used to create a new pool for code intended to be used in production.

func NewPool

func NewPool(ctx context.Context, connString string) (Pool, error)

NewPool creates a new database connection pool for use in production code. It returns a private type, that implements the Pool interface.

Jump to

Keyboard shortcuts

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