internal

package
v0.3.0-prerelease.5 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package internal contains utilities and helper functions useful in the scope of eventually's postgres implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTransaction

func RunTransaction(
	ctx context.Context,
	db TxBeginner,
	options pgx.TxOptions,
	do func(ctx context.Context, tx pgx.Tx) error,
) (err error)

RunTransaction runs a critical data change path in a transaction, seamlessly handling the transaction lifecycle (begin, commit, rollback).

Types

type PostgresContainer

type PostgresContainer struct {
	*postgres.PostgresContainer

	ConnectionDSN  string
	PostgresConfig *pgx.ConnConfig
}

PostgresContainer returns an handle on a Postgres container started through testcontainers.

func NewPostgresContainer

func NewPostgresContainer(ctx context.Context) (*PostgresContainer, error)

NewPostgresContainer creates and starts a new Postgres container using testcontainers, then returns a handle to said container to manage its lifecycle.

type TxBeginner

type TxBeginner interface {
	BeginTx(ctx context.Context, options pgx.TxOptions) (pgx.Tx, error)
}

TxBeginner represents a pgx-related component that can initiate transactions.

Jump to

Keyboard shortcuts

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