mysql

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"sql",
	fx.Provide(New),
	fx.Invoke(NewMigrator),
)

Functions

func New

func New(settings Settings) (*sql.DB, error)

Types

type MDuration

type MDuration struct {
	time.Duration
}

func (*MDuration) UnmarshalJSON

func (d *MDuration) UnmarshalJSON(data []byte) error

type Migrator

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

func NewMigrator

func NewMigrator(lc fx.Lifecycle, settings Settings, log *zap.SugaredLogger) *Migrator

type Settings

type Settings struct {
	Connection string `yaml:"connection"`
	// User can also be specified separately from the connection string
	User string `yaml:"user"`
	// Password can also be specified separately from the connection string
	Password string `yaml:"password"`
	// User can also be specified separately from the connection string
	MigrateUser string `yaml:"migrateUser"`
	// Password can also be specified separately from the connection string
	MigratePassword string `yaml:"migratePassword"`
	// MaxLifetime is the maximum lifetime of a connection
	// from time.ParseDuration:
	// A duration string is a possibly signed sequence of
	// decimal numbers, each with optional fraction and a unit suffix,
	// such as "300ms", "-1.5h" or "2h45m".
	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	MaxLifetime        MDuration `yaml:"maxLifetime"`
	MaxOpenConnections int       `yaml:"maxOpenConnections"`
	MaxIdleConnections int       `yaml:"maxIdleConnections"`
	MigrationPath      string    `yaml:"migrationPath"`
}

func (*Settings) ConnectionUrl

func (d *Settings) ConnectionUrl(migration bool) (string, error)

Jump to

Keyboard shortcuts

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