sql

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2018 License: MIT Imports: 5 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 AppConfig added in v0.7.0

type AppConfig struct {
	Host string `env:"" required:"true"`
	Port int    `env:"" default:"3306"`
	User string `env:"" required:"true"`
	Pass string `env:""` // Required removed for now because empty value is not supported by Viper
	Name string `env:"" required:"true"`
}

AppConfig can be used in an application config to represent database connection details. It supports github.com/goph/nest

func (AppConfig) Dsn added in v0.7.0

func (c AppConfig) Dsn() string

Dsn returns the DSN created form the configuration.

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