sql

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(params ConnectionParams) (*sql.DB, error)

NewConnection creates a new database connection and optionally registers a health check. It also registers a closer in the application lifecycle.

Types

type Config

type Config struct {
	Driver string
	Dsn    string
}

Config holds a list of options used during the debug server construction.

func NewConfig

func NewConfig(driver string, dsn string) *Config

NewConfig returns a new config populated with default values.

type ConnectionParams

type ConnectionParams struct {
	dig.In

	Config          *Config
	HealthCollector healthz.Collector `optional:"true"`
	Lifecycle       fxt.Lifecycle
}

ConnectionParams provides a set of dependencies for a database connection constructor.

type MasterSlaveConfigResult

type MasterSlaveConfigResult struct {
	dig.Out

	Master *Config `name:"master"`
	Slave  *Config `name:"slave"`
}

MasterSlaveConfigResult can be used to register master and slave configurations in the container.

type MasterSlaveConnectionParams

type MasterSlaveConnectionParams struct {
	dig.In

	MasterConfig    *Config           `name:"master"`
	SlaveConfig     *Config           `name:"slave"`
	HealthCollector healthz.Collector `optional:"true"`
	Lifecycle       fxt.Lifecycle
}

MasterSlaveConnectionParams provides a set of dependencies for a master-slave database connection constructor.

type MasterSlaveConnectionResult

type MasterSlaveConnectionResult struct {
	dig.Out

	Master *sql.DB `name:"master"`
	Slave  *sql.DB `name:"slave"`
}

MasterSlaveConnectionResult contains the result connections of the NewMasterSlaveConnection constructor.

func NewMasterSlaveConnection

func NewMasterSlaveConnection(params MasterSlaveConnectionParams) (MasterSlaveConnectionResult, error)

NewMasterSlaveConnection calls NewConnection twice with different input configurations.

Jump to

Keyboard shortcuts

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