stdenttxfx

package
v0.0.194 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package stdenttxfx provides database transactors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provide

func Provide[T stdent.Tx, C stdent.Client[T]](applicationName string, clientFactory ClientFactoryFunc[T, C]) fx.Option

Provide provides the standard read-write/read-only separation.

func TestProvide

func TestProvide[T stdent.Tx, C stdent.Client[T]](
	applicationName,
	endRoleUsername,
	endRolePassword string,
	clientFactory ClientFactoryFunc[T, C],
) fx.Option

TestProvide provides project-specific transactor config to make it easy for any test package to interact with the database.

Types

type ClientFactoryFunc

type ClientFactoryFunc[T stdent.Tx, C stdent.Client[T]] = func(driver dialect.Driver) C

type Config

type Config struct {
	TestMaxQueryCosts float64 `env:"TEST_MAX_QUERY_COSTS"`
}

Config configures the transact components.

type Params

type Params[T stdent.Tx, C stdent.Client[T]] struct {
	fx.In
	fx.Lifecycle
	Config
	RW            *sql.DB `name:"rw"`
	RO            *sql.DB `name:"ro"`
	ClientFactory ClientFactoryFunc[T, C]
	TxBeginSQL    stdent.BeginHookFunc `optional:"true"`
}

Params describe fx params for creating the transactors.

type Result

type Result[T stdent.Tx] struct {
	fx.Out
	ReadWrite *stdent.Transactor[T] `name:"rw"`
	ReadOnly  *stdent.Transactor[T] `name:"ro"`
}

Result describes the fx components this package produces.

func New

func New[T stdent.Tx, C stdent.Client[T]](params Params[T, C]) (Result[T], error)

New provides the transactors.

Jump to

Keyboard shortcuts

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