sqlfx

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoquModule = fx.Module("geck/persistence/sql/goqu",
	fx.Invoke(
		func() {
			goqu.SetTimeLocation(time.UTC)
		},
	),
)

GoquModule is the `uber/fx` module of the goqu package.

View Source
var InterceptorModule = fx.Module("geck/persistence/sql/interceptors",
	fx.Provide(
		func(deps databaseInterceptorsDeps) gecksql.DB {
			opts := make([]gecksql.DatabaseOption, 0, len(deps.Interceptors))
			for _, interceptor := range deps.Interceptors {
				opts = append(opts, gecksql.WithInterceptor(interceptor))
			}
			return gecksql.NewDB(deps.Database, opts...)
		},
	),
)

InterceptorModule is a `uber/fx` module providing gecksql.DBInterceptor instances so driver-specific submodules can integrate additional behavior (e.g. observability, transaction contexts) into their concrete implementations of gecksql.DB.

View Source
var ObservabilityModule = fx.Module("geck/persistence/sql/interceptors/observability",
	fx.Provide(
		AsDBInterceptor(gecksql.NewDatabaseLogger),
	),
)

ObservabilityModule is a `uber/fx` module providing gecksql.DBInterceptor instances so driver-specific submodules can integrate observability tools (i.e. logging, metrics, tracing) into their concrete implementations of gecksql.DB.

Requires to be declared along InterceptorModule.

View Source
var TransactionModule = fx.Module("geck/persistence/sql/interceptors/tx",
	fx.Provide(
		AsDBInterceptor(gecksql.NewDatabaseTxPropagator),
	),
)

TransactionModule is a `uber/fx` module providing a gecksql.DatabaseTxPropagator instance (as gecksql.DBInterceptor) so driver-specific submodules can integrate transaction propagation features into their concrete implementations of gecksql.DB.

Requires to be declared along InterceptorModule.

Functions

func AsDB

func AsDB(t any) any

AsDB annotates `t` as a gecksql.DB implementation.

This annotation only works for `uber/fx` providers.

func AsDBInterceptor

func AsDBInterceptor(t any) any

AsDBInterceptor annotates `t` as a gecksql.DBInterceptor implementation.

This annotation only works for `uber/fx` providers.

In addition, it adds `t` into the SQL database interceptor group, meaning the dependency framework will aggregate all components annotated by this routine to later offer them to other components in form of a slice for its usage.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳