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
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.