datasource

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueryReturnedNoRows indicates a query expected exactly one row but found none.
	ErrQueryReturnedNoRows = errors.New("query returned no rows")

	// ErrQueryReturnedMultipleRows indicates a query expected exactly one row but found more. Often wraps
	// pgx.ErrTooManyRows or similar driver errors.
	ErrQueryReturnedMultipleRows = errors.New("query returned multiple rows")

	// ErrDataSourceClosed indicates an operation was attempted on a closed data source.
	ErrDataSourceClosed = errors.New("data source is closed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	DSN string
}

func (Config) Valid

func (c Config) Valid(_ context.Context) map[string]string

type DataSource

type DataSource interface {
	FetchData(ctx context.Context, query string) (map[string]any, error)
	Close(ctx context.Context) error
}

type PostgresDataSource

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

func NewPostgresDataSource

func NewPostgresDataSource(ctx context.Context, cfg Config, logger *slog.Logger) (*PostgresDataSource, error)

func (*PostgresDataSource) Close

func (p *PostgresDataSource) Close(ctx context.Context) error

func (*PostgresDataSource) FetchData

func (p *PostgresDataSource) FetchData(ctx context.Context, query string) (map[string]any, error)

Jump to

Keyboard shortcuts

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