query

package
v2025.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("database",
	fx.Provide(
		SetupDB,
	),
	fx.Decorate(wrapLogger),
)

Functions

func MigrateDB

func MigrateDB(
	logger *zap.Logger,
	dbDSN string,
	ignoreReqs bool,
	esxCompat bool,
	disableLocking bool,
) (*reqs.DBReqs, error)

MigrateDB runs database migrations using golang-migrate, logging progress and errors. It prepares the DSN, connects to the DB, runs migrations, and logs the result.

func NewMigrate

func NewMigrate(db *sql.DB, esxCompat bool, disableLocking bool) (*migrate.Migrate, error)

NewMigrate creates a new migrate.Migrate instance for the given DB and ESX compatibility flag. It sets up the migration source and driver, and injects template data for migration scripts.

Types

type MigrateLogger

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

MigrateLogger implements the migrate.Logger interface using zap.Logger for logging migration output.

func NewMigrateLogger

func NewMigrateLogger(logger *zap.Logger) *MigrateLogger

NewMigrateLogger creates a new MigrateLogger with the given zap.Logger. The logger is named "migrate" and verbosity is set based on the logger's level.

func (*MigrateLogger) Printf

func (l *MigrateLogger) Printf(format string, v ...any)

Printf logs formatted migration output using zap at Info level.

func (*MigrateLogger) Verbose

func (l *MigrateLogger) Verbose() bool

Verbose returns true if verbose logging output is wanted for migrations.

type Params

type Params struct {
	fx.In

	// LC is the Fx lifecycle for managing start/stop hooks.
	LC fx.Lifecycle

	// Logger is the zap logger instance for logging.
	Logger *zap.Logger
	// Config is the application configuration.
	Config *config.Config
}

Params contains dependencies for constructing the database connection and managing its lifecycle.

type Result added in v2025.8.0

type Result struct {
	fx.Out

	// DB is the SQL database connection instance.
	DB *sql.DB
	// Reqs is the database requirements instance.
	Reqs *reqs.DBReqs
}

Result holds the result of the database setup.

func SetupDB

func SetupDB(p Params) (Result, error)

SetupDB sets up the database connection, runs migrations (unless skipped), configures connection pool, metrics, and ESX compatibility, and registers a stop hook for cleanup. Returns a *sql.DB instance or an error.

Directories

Path Synopsis
fivenet

Jump to

Keyboard shortcuts

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