txn_mongo

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute[T any, D Doer[T]](
	ctx context.Context, mod Module, do D,
	fn txn.DoFunc[Options, Beginner, D], setters ...txn.DoerFieldSetter,
) (D, error)

func ExecuteOnce

func ExecuteOnce[D txn.Doer[Options, Beginner]](
	ctx context.Context, beginner Beginner, do D, fn txn.DoFunc[Options, Beginner, D]) error

ExecuteOnce executes a pgx transaction.

func Ping

func Ping(beginner Beginner, limit int, count txn.PingCount) (int, error)

Ping performs a ping operation.

Types

type Beginner

type Beginner = *mongo.Client

type Doer

type Doer[T any] interface {
	txn.Doer[Options, Beginner]
	DefaultSetters(title string) []txn.DoerFieldSetter
	Client() T
	SetClient(T)
}

Doer defines the interface for PGX transaction operations.

type DoerBase

type DoerBase[T any] struct {
	txn.DoerBase[Options, Beginner]
	// contains filtered or unexported fields
}

DoerBase provides a base implementation for the Doer interface.

func (*DoerBase[T]) Client

func (do *DoerBase[T]) Client() T

Client returns the client.

func (*DoerBase[_]) DefaultSetters

func (do *DoerBase[_]) DefaultSetters(title string) []txn.DoerFieldSetter

func (*DoerBase[T]) SetClient

func (do *DoerBase[T]) SetClient(value T)

SetClient sets the client.

type Module

type Module interface {
	Beginner() Beginner
}

type ModuleBase

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

func (*ModuleBase) Beginner

func (b *ModuleBase) Beginner() Beginner

func (*ModuleBase) Mutate added in v0.0.10

func (b *ModuleBase) Mutate(setters ...ModuleSetter)

type ModuleSetter added in v0.0.10

type ModuleSetter func(*ModuleBase)

func WithBeginner added in v0.0.10

func WithBeginner(value Beginner) ModuleSetter

type Options

type Options = *mongoOptions

type RawTx added in v0.0.10

type RawTx = mongo.Session

type RawTxn added in v0.0.10

type RawTxn interface {
	txn.Txn
	Raw() RawTx
}

func BeginTxn

func BeginTxn(ctx context.Context, _ Beginner, opt Options) (RawTxn, error)

BeginTxn begins a pgx transaction.

Jump to

Keyboard shortcuts

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