dialectors

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDialector

func NewDialector[InputType dialectorInputType](input InputType) gorm.Dialector

NewDialector creates a new GORM dialector using the given input configurations. It automatically selects between a MySQL or Postgres dialector depending on the input configuration type.

Types

type DialectorInput

type DialectorInput struct {
	// A function that determines whether a new configuration should be used
	// for the next connection
	ShouldReconfigureCallback connectors.ShouldReconfigureCallback
	// The maximum duration to allow a connection to remain idle before closing it
	ConnMaxIdleTime *time.Duration
	// The maximum duration to allow a connection to remain open (regardless of
	// whether it is idle) before closing it
	ConnMaxLifetime *time.Duration
	// The maximum number of idle connections that can remain open
	MaxIdleConns *int
	// The maximum number of connections (regardless of whether they are idle)
	// that can be open at any given time.
	MaxOpenConns *int
}

The common (relevant to all database types) configuration values that should be used for new connections.

type MysqlDialectorInput

type MysqlDialectorInput struct {
	// Common (not specific to MySQL) input values
	DialectorInput

	// The GORM-specific MySQL configuration values to use
	GormMysqlConfig gormmysql.Config

	// A function that gets the config to use for the next
	// MySQL connection
	GetMysqlConfigCallback connectors.GetMysqlConfigCallback
}

func (MysqlDialectorInput) Clone

Returns a new copy of the MysqlDialectorInput struct

type PostgresDialectorInput

type PostgresDialectorInput struct {
	// Common (not specific to PostgreSQL) input values
	DialectorInput

	// The GORM-specific PostgreSQL configuration values to use
	GormPostgresConfig gormpostgres.Config

	// A function that gets the config to use for the next
	// PostgreSQL connection
	GetPostgresConfigCallback connectors.GetPostgresConfigCallback
}

func (PostgresDialectorInput) Clone

Returns a new copy of the PostgresDialectorInput struct

Jump to

Keyboard shortcuts

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