adapters

package
v1.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package adapters provide database adapter implementations for the PostgreSQL event store.

This package implements the adapter pattern to support multiple PostgreSQL database libraries: pgx.Pool, sql.DB, and sqlx.DB. All adapters provide equivalent functionality through a common DBAdapter interface, allowing the event store to work seamlessly with any supported database connection type.

The adapters handle the specifics of each database library while presenting a unified interface for query execution and result handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBAdapter

type DBAdapter interface {
	Query(ctx context.Context, query string) (DBRows, error)
	Exec(ctx context.Context, query string) (DBResult, error)
}

DBAdapter defines the interface for database operations needed by the event store.

type DBResult

type DBResult interface {
	RowsAffected() (int64, error)
}

DBResult defines the interface for execution results.

type DBRows

type DBRows interface {
	Next() bool
	Scan(dest ...any) error
	Close() error
}

DBRows defines the interface for query result rows.

type PGXAdapter

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

PGXAdapter implements DBAdapter for pgxpool.Pool.

func NewPGXAdapter

func NewPGXAdapter(pool *pgxpool.Pool) *PGXAdapter

NewPGXAdapter creates a new PGX adapter.

func (*PGXAdapter) Exec

func (p *PGXAdapter) Exec(ctx context.Context, query string) (DBResult, error)

Exec executes a query using the pgx pool and returns wrapped result.

func (*PGXAdapter) Query

func (p *PGXAdapter) Query(ctx context.Context, query string) (DBRows, error)

Query executes a query using the pgx pool and returns wrapped rows.

type SQLAdapter

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

SQLAdapter implements DBAdapter for sql.DB.

func NewSQLAdapter

func NewSQLAdapter(db *sql.DB) *SQLAdapter

NewSQLAdapter creates a new SQL adapter.

func (*SQLAdapter) Exec

func (s *SQLAdapter) Exec(ctx context.Context, query string) (DBResult, error)

Exec executes a query using the sql.DB and returns a wrapped result.

func (*SQLAdapter) Query

func (s *SQLAdapter) Query(ctx context.Context, query string) (DBRows, error)

Query executes a query using the sql.DB and returns wrapped rows.

type SQLXAdapter

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

SQLXAdapter implements DBAdapter for sqlx.DB.

func NewSQLXAdapter

func NewSQLXAdapter(db *sqlx.DB) *SQLXAdapter

NewSQLXAdapter creates a new SQLX adapter.

func (*SQLXAdapter) Exec

func (s *SQLXAdapter) Exec(ctx context.Context, query string) (DBResult, error)

Exec executes a query using the sqlx.DB and returns a wrapped result.

func (*SQLXAdapter) Query

func (s *SQLXAdapter) Query(ctx context.Context, query string) (DBRows, error)

Query executes a query using the sqlx.DB and returns wrapped rows.

Jump to

Keyboard shortcuts

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